| 6 | extern "C" { |
| 7 | #include <libavutil/timestamp.h> |
| 8 | #include <libavformat/avformat.h> |
| 9 | #include <libavcodec/avcodec.h> |
| 10 | } |
| 11 |
| 12 | #include <string> |
| 13 | #include <bitset> |
| 14 | #include <set> |
| 15 | #include <map> |
| 16 |
| 17 | namespace tgcalls { |
| 18 |
| 19 | namespace { |
| 20 |
| 21 | uint32_t stringToUInt32(std::string const &string) { |
| 22 | std::stringstream stringStream(string); |
| 23 | uint32_t value = 0; |
| 24 | stringStream >> value; |
| 25 | return value; |
| 26 | } |
| 27 |
| 28 | template <typename Out> |
| 29 | void splitString(const std::string &s, char delim, Out result) { |
| 30 | std::istringstream iss(s); |
| 31 | std::string item; |
| 32 | while (std::getline(iss, item, delim)) { |
| 33 | *result++ = item; |
| 34 | } |
| 35 | } |
| 36 |
| 37 | std::vector<std::string> splitString(const std::string &s, char delim) { |
| 38 | std::vector<std::string> elems; |
| 39 | splitString(s, delim, std::back_inserter(elems)); |
| 40 | return elems; |
| 41 | } |
| 42 |
| 43 | static absl::optional<uint32_t> readInt32(std::string const &data, int &offset) { |
| 44 | if (offset + 4 > data.length()) { |
| 45 | return absl::nullopt; |
| 46 | } |
| 47 |
| 48 | int32_t value = 0; |
| 49 | memcpy(&value, data.data() + offset, 4); |
| 50 | offset += 4; |
| 51 |
| 52 | return value; |
| 53 | } |
| 54 |
| 55 | struct ChannelUpdate { |
| 56 | int frameIndex = 0; |
| 57 | int id = 0; |
| 58 | uint32_t ssrc = 0; |
| 59 | }; |
| 60 |
| 61 | static std::vector<ChannelUpdate> parseChannelUpdates(std::string const &data, int &offset) { |
| 62 | std::vector<ChannelUpdate> result; |
| 63 |
| 64 | auto channels = readInt32(data, offset); |
| 65 | if (!channels) { |
| 66 | return {}; |
| 67 | } |
| 68 |
| 69 | auto count = readInt32(data, offset); |
| 70 | if (!count) { |
| 71 | return {}; |
| 72 | } |
| 73 |
| 74 | for (int i = 0; i < count.value(); i++) { |
| 75 | auto frameIndex = readInt32(data, offset); |
| 76 | if (!frameIndex) { |
| 77 | return {}; |
| 78 | } |
| 79 |
| 80 | auto channelId = readInt32(data, offset); |
| 81 | if (!channelId) { |
| 82 | return {}; |
| 83 | } |
| 84 |
| 85 | auto ssrc = readInt32(data, offset); |
| 86 | if (!ssrc) { |
| 87 | return {}; |
| 88 | } |
| 89 |
| 90 | ChannelUpdate update; |
| 91 | update.frameIndex = frameIndex.value(); |
| 92 | update.id = channelId.value(); |
| 93 | update.ssrc = ssrc.value(); |
| 94 |
| 95 | result.push_back(update); |
| 96 | } |
| 97 |
| 98 | return result; |
| 99 | } |
| 100 |
| 101 | class AVIOContextImpl { |
| 102 | public: |
| 103 | AVIOContextImpl(std::vector<uint8_t> &&fileData) : |
| 104 | _fileData(std::move(fileData)) { |
| 105 | _buffer.resize(4 * 1024); |
| 106 | _context = avio_alloc_context(_buffer.data(), (int)_buffer.size(), 0, this, &AVIOContextImpl::read, NULL, &AVIOContextImpl::seek); |
| 107 | } |
| 108 |
| 109 | ~AVIOContextImpl() { |
| 110 | av_free(_context); |
| 111 | } |
| 112 |
| 113 | static int read(void *opaque, unsigned char *buffer, int bufferSize) { |
| 114 | AVIOContextImpl *instance = static_cast<AVIOContextImpl *>(opaque); |
| 115 |
| 116 | int bytesToRead = std::min(bufferSize, ((int)instance->_fileData.size()) - instance->_fileReadPosition); |
| 117 | if (bytesToRead < 0) { |
| 118 | bytesToRead = 0; |
| 119 | } |
| 120 |
| 121 | if (bytesToRead > 0) { |
| 122 | memcpy(buffer, instance->_fileData.data() + instance->_fileReadPosition, bytesToRead); |
| 123 | instance->_fileReadPosition += bytesToRead; |
| 124 |
| 125 | return bytesToRead; |
| 126 | } else { |
| 127 | return AVERROR_EOF; |
| 128 | } |
| 129 | } |
| 130 |
| 131 | static int64_t seek(void *opaque, int64_t offset, int whence) { |
| 132 | AVIOContextImpl *instance = static_cast<AVIOContextImpl *>(opaque); |
| 133 |
| 134 | if (whence == 0x10000) { |
| 135 | return (int64_t)instance->_fileData.size(); |
| 136 | } else { |
| 137 | int64_t seekOffset = std::min(offset, (int64_t)instance->_fileData.size()); |
| 138 | if (seekOffset < 0) { |
| 139 | seekOffset = 0; |
| 140 | } |
| 141 | instance->_fileReadPosition = (int)seekOffset; |
| 142 | return seekOffset; |
| 143 | } |
| 144 | } |
| 145 |
| 146 | AVIOContext *getContext() { |
| 147 | return _context; |
| 148 | } |
| 149 |
| 150 | private: |
| 151 | std::vector<uint8_t> _fileData; |
| 152 | int _fileReadPosition = 0; |
| 153 |
| 154 | std::vector<uint8_t> _buffer; |
| 155 | AVIOContext *_context = nullptr; |
| 156 | }; |
| 157 |
| 158 | } |
| 159 |
| 160 | struct ReadPcmResult { |
| 161 | int numSamples = 0; |
| 162 | int numChannels = 0; |
| 163 | }; |
| 164 |
| 165 | class AudioStreamingPartInternal { |
| 166 | public: |
| 167 | AudioStreamingPartInternal(std::vector<uint8_t> &&fileData) : |
| 168 | _avIoContext(std::move(fileData)) { |
| 169 | int ret = 0; |
| 170 |
| 171 | _frame = av_frame_alloc(); |
| 172 |
| 173 | AVInputFormat *inputFormat = av_find_input_format("ogg"); |
| 174 | if (!inputFormat) { |
| 175 | _didReadToEnd = true; |
| 176 | return; |
| 177 | } |
| 178 |
| 179 | _inputFormatContext = avformat_alloc_context(); |
| 180 | if (!_inputFormatContext) { |
| 181 | _didReadToEnd = true; |
| 182 | return; |
| 183 | } |
| 184 |
| 185 | _inputFormatContext->pb = _avIoContext.getContext(); |
| 186 |
| 187 | if ((ret = avformat_open_input(&_inputFormatContext, "", inputFormat, nullptr)) < 0) { |
| 188 | _didReadToEnd = true; |
| 189 | return; |
| 190 | } |
| 191 |
| 192 | if ((ret = avformat_find_stream_info(_inputFormatContext, nullptr)) < 0) { |
| 193 | _didReadToEnd = true; |
| 194 |
| 195 | avformat_close_input(&_inputFormatContext); |
| 196 | _inputFormatContext = nullptr; |
| 197 | return; |
| 198 | } |
| 199 |
| 200 | AVCodecParameters *audioCodecParameters = nullptr; |
| 201 | AVStream *audioStream = nullptr; |
| 202 | for (int i = 0; i < _inputFormatContext->nb_streams; i++) { |
| 203 | AVStream *inStream = _inputFormatContext->streams[i]; |
| 204 |
| 205 | AVCodecParameters *inCodecpar = inStream->codecpar; |
| 206 | if (inCodecpar->codec_type != AVMEDIA_TYPE_AUDIO) { |
| 207 | continue; |
| 208 | } |
| 209 | audioCodecParameters = inCodecpar; |
| 210 | audioStream = inStream; |
| 211 |
| 212 | _durationInMilliseconds = (int)((inStream->duration + inStream->first_dts) * 1000 / 48000); |
| 213 |
| 214 | if (inStream->metadata) { |
| 215 | AVDictionaryEntry *entry = av_dict_get(inStream->metadata, "TG_META", nullptr, 0); |
| 216 | if (entry && entry->value) { |
| 217 | std::string result; |
| 218 | size_t data_used = 0; |
| 219 | std::string sourceBase64 = (const char *)entry->value; |
| 220 | rtc::Base64::Decode(sourceBase64, rtc::Base64::DO_LAX, &result, &data_used); |
| 221 |
| 222 | if (result.size() != 0) { |
| 223 | int offset = 0; |
| 224 | _channelUpdates = parseChannelUpdates(result, offset); |
| 225 | } |
| 226 | } |
| 227 |
| 228 | uint32_t videoChannelMask = 0; |
| 229 | entry = av_dict_get(inStream->metadata, "ACTIVE_MASK", nullptr, 0); |
| 230 | if (entry && entry->value) { |
| 231 | std::string sourceString = (const char *)entry->value; |
| 232 | videoChannelMask = stringToUInt32(sourceString); |
| 233 | } |
| 234 |
| 235 | std::vector<std::string> endpointList; |
| 236 | entry = av_dict_get(inStream->metadata, "ENDPOINTS", nullptr, 0); |
| 237 | if (entry && entry->value) { |
| 238 | std::string sourceString = (const char *)entry->value; |
| 239 | endpointList = splitString(sourceString, ' '); |
| 240 | } |
| 241 |
| 242 | std::bitset<32> videoChannels(videoChannelMask); |
| 243 | size_t endpointIndex = 0; |
| 244 | if (videoChannels.count() == endpointList.size()) { |
| 245 | for (size_t i = 0; i < videoChannels.size(); i++) { |
| 246 | if (videoChannels[i]) { |
| 247 | _endpointMapping.insert(std::make_pair(endpointList[endpointIndex], i)); |
| 248 | endpointIndex++; |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | } |
| 253 |
| 254 | break; |
| 255 | } |
| 256 |
| 257 | if (audioCodecParameters && audioStream) { |
| 258 | AVCodec *codec = avcodec_find_decoder(audioCodecParameters->codec_id); |
| 259 | if (codec) { |
| 260 | _codecContext = avcodec_alloc_context3(codec); |
| 261 | ret = avcodec_parameters_to_context(_codecContext, audioCodecParameters); |
| 262 | if (ret < 0) { |
| 263 | _didReadToEnd = true; |
| 264 |
| 265 | avcodec_free_context(&_codecContext); |
| 266 | _codecContext = nullptr; |
| 267 | } else { |
| 268 | _codecContext->pkt_timebase = audioStream->time_base; |
| 269 |
| 270 | _channelCount = _codecContext->channels; |
| 271 |
| 272 | ret = avcodec_open2(_codecContext, codec, nullptr); |
| 273 | if (ret < 0) { |
| 274 | _didReadToEnd = true; |
| 275 |
| 276 | avcodec_free_context(&_codecContext); |
| 277 | _codecContext = nullptr; |
| 278 | } |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 |
| 284 | ~AudioStreamingPartInternal() { |
| 285 | if (_frame) { |
| 286 | av_frame_unref(_frame); |
| 287 | } |
| 288 | if (_codecContext) { |
| 289 | avcodec_close(_codecContext); |
| 290 | avcodec_free_context(&_codecContext); |
| 291 | } |
| 292 | if (_inputFormatContext) { |
| 293 | avformat_close_input(&_inputFormatContext); |
| 294 | } |
| 295 | } |
| 296 |
| 297 | ReadPcmResult readPcm(std::vector<int16_t> &outPcm) { |
| 298 | int outPcmSampleOffset = 0; |
| 299 | ReadPcmResult result; |
| 300 |
| 301 | int readSamples = (int)outPcm.size() / _channelCount; |
| 302 |
| 303 | result.numChannels = _channelCount; |
| 304 |
| 305 | while (outPcmSampleOffset < readSamples) { |
| 306 | if (_pcmBufferSampleOffset >= _pcmBufferSampleSize) { |
| 307 | fillPcmBuffer(); |
| 308 |
| 309 | if (_pcmBufferSampleOffset >= _pcmBufferSampleSize) { |
| 310 | break; |
| 311 | } |
| 312 | } |
| 313 |
| 314 | int readFromPcmBufferSamples = std::min(_pcmBufferSampleSize - _pcmBufferSampleOffset, readSamples - outPcmSampleOffset); |
| 315 | if (readFromPcmBufferSamples != 0) { |
| 316 | std::copy(_pcmBuffer.begin() + _pcmBufferSampleOffset * _channelCount, _pcmBuffer.begin() + _pcmBufferSampleOffset * _channelCount + readFromPcmBufferSamples * _channelCount, outPcm.begin() + outPcmSampleOffset * _channelCount); |
| 317 | _pcmBufferSampleOffset += readFromPcmBufferSamples; |
| 318 | outPcmSampleOffset += readFromPcmBufferSamples; |
| 319 | result.numSamples += readFromPcmBufferSamples; |
| 320 | } |
| 321 | } |
| 322 |
| 323 | return result; |
| 324 | } |
| 325 |
| 326 | int getDurationInMilliseconds() { |
| 327 | return _durationInMilliseconds; |
| 328 | } |
| 329 |
| 330 | int getChannelCount() { |
| 331 | return _channelCount; |
| 332 | } |
| 333 |
| 334 | std::vector<ChannelUpdate> const &getChannelUpdates() const { |
| 335 | return _channelUpdates; |
| 336 | } |
| 337 |
| 338 | std::map<std::string, int32_t> getEndpointMapping() const { |
| 339 | return _endpointMapping; |
| 340 | } |
| 341 |
| 342 | private: |
| 343 | static int16_t sampleFloatToInt16(float sample) { |
| 344 | return av_clip_int16 (static_cast<int32_t>(lrint(sample*32767))); |
| 345 | } |
| 346 |
| 347 | void fillPcmBuffer() { |
| 348 | _pcmBufferSampleSize = 0; |
| 349 | _pcmBufferSampleOffset = 0; |
| 350 |
| 351 | if (_didReadToEnd) { |
| 352 | return; |
| 353 | } |
| 354 | if (!_inputFormatContext) { |
| 355 | _didReadToEnd = true; |
| 356 | return; |
| 357 | } |
| 358 | if (!_codecContext) { |
| 359 | _didReadToEnd = true; |
| 360 | return; |
| 361 | } |
| 362 |
| 363 | int ret = 0; |
| 364 | do { |
| 365 | ret = av_read_frame(_inputFormatContext, &_packet); |
| 366 | if (ret < 0) { |
| 367 | _didReadToEnd = true; |
| 368 | return; |
| 369 | } |
| 370 |
| 371 | ret = avcodec_send_packet(_codecContext, &_packet); |
| 372 | if (ret < 0) { |
| 373 | _didReadToEnd = true; |
| 374 | return; |
| 375 | } |
| 376 |
| 377 | int bytesPerSample = av_get_bytes_per_sample(_codecContext->sample_fmt); |
| 378 | if (bytesPerSample != 2 && bytesPerSample != 4) { |
| 379 | _didReadToEnd = true; |
| 380 | return; |
| 381 | } |
| 382 |
| 383 | ret = avcodec_receive_frame(_codecContext, _frame); |
| 384 | } while (ret == AVERROR(EAGAIN)); |
| 385 |
| 386 | if (ret != 0) { |
| 387 | _didReadToEnd = true; |
| 388 | return; |
| 389 | } |
| 390 | if (_frame->channels != _channelCount || _frame->channels > 8) { |
| 391 | _didReadToEnd = true; |
| 392 | return; |
| 393 | } |
| 394 |
| 395 | if (_pcmBuffer.size() < _frame->nb_samples * _frame->channels) { |
| 396 | _pcmBuffer.resize(_frame->nb_samples * _frame->channels); |
| 397 | } |
| 398 |
| 399 | switch (_codecContext->sample_fmt) { |
| 400 | case AV_SAMPLE_FMT_S16: { |
| 401 | memcpy(_pcmBuffer.data(), _frame->data[0], _frame->nb_samples * 2 * _frame->channels); |
| 402 | } break; |
| 403 |
| 404 | case AV_SAMPLE_FMT_S16P: { |
| 405 | int16_t *to = _pcmBuffer.data(); |
| 406 | for (int sample = 0; sample < _frame->nb_samples; ++sample) { |
| 407 | for (int channel = 0; channel < _frame->channels; ++channel) { |
| 408 | int16_t *shortChannel = (int16_t*)_frame->data[channel]; |
| 409 | *to++ = shortChannel[sample]; |
| 410 | } |
| 411 | } |
| 412 | } break; |
| 413 |
| 414 | case AV_SAMPLE_FMT_FLT: { |
| 415 | float *floatData = (float *)&_frame->data[0]; |
| 416 | for (int i = 0; i < _frame->nb_samples * _frame->channels; i++) { |
| 417 | _pcmBuffer[i] = sampleFloatToInt16(floatData[i]); |
| 418 | } |
| 419 | } break; |
| 420 |
| 421 | case AV_SAMPLE_FMT_FLTP: { |
| 422 | int16_t *to = _pcmBuffer.data(); |
| 423 | for (int sample = 0; sample < _frame->nb_samples; ++sample) { |
| 424 | for (int channel = 0; channel < _frame->channels; ++channel) { |
| 425 | float *floatChannel = (float*)_frame->data[channel]; |
| 426 | *to++ = sampleFloatToInt16(floatChannel[sample]); |
| 427 | } |
| 428 | } |
| 429 | } break; |
| 430 |
| 431 | default: { |
| 432 | //RTC_FATAL() << "Unexpected sample_fmt"; |
| 433 | } break; |
| 434 | } |
| 435 |
| 436 | _pcmBufferSampleSize = _frame->nb_samples; |
| 437 | _pcmBufferSampleOffset = 0; |
| 438 | } |
| 439 |
| 440 | private: |
| 441 | AVIOContextImpl _avIoContext; |
| 442 |
| 443 | AVFormatContext *_inputFormatContext = nullptr; |
| 444 | AVPacket _packet; |
| 445 | AVCodecContext *_codecContext = nullptr; |
| 446 | AVFrame *_frame = nullptr; |
| 447 |
| 448 | bool _didReadToEnd = false; |
| 449 |
| 450 | int _durationInMilliseconds = 0; |
| 451 | int _channelCount = 0; |
| 452 |
| 453 | std::vector<ChannelUpdate> _channelUpdates; |
| 454 | std::map<std::string, int32_t> _endpointMapping; |
| 455 |
| 456 | std::vector<int16_t> _pcmBuffer; |
| 457 | int _pcmBufferSampleOffset = 0; |
| 458 | int _pcmBufferSampleSize = 0; |
| 459 | }; |
| 460 |
| 461 | class AudioStreamingPartState { |
| 462 | struct ChannelMapping { |
| 463 | uint32_t ssrc = 0; |
| 464 | int channelIndex = 0; |
| 465 |
| 466 | ChannelMapping(uint32_t ssrc_, int channelIndex_) : |
| 467 | ssrc(ssrc_), channelIndex(channelIndex_) { |
| 468 | } |
| 469 | }; |
| 470 |
| 471 | public: |
| 472 | AudioStreamingPartState(std::vector<uint8_t> &&data) : |
| 473 | _parsedPart(std::move(data)) { |
| 474 | if (_parsedPart.getChannelUpdates().size() == 0) { |
| 475 | _didReadToEnd = true; |
| 476 | return; |
| 477 | } |
| 478 |
| 479 | _remainingMilliseconds = _parsedPart.getDurationInMilliseconds(); |
| 480 | _pcm10ms.resize(480 * _parsedPart.getChannelCount()); |
| 481 |
| 482 | for (const auto &it : _parsedPart.getChannelUpdates()) { |
| 483 | _allSsrcs.insert(it.ssrc); |
| 484 | } |
| 485 | } |
| 486 |
| 487 | ~AudioStreamingPartState() { |
| 488 | } |
| 489 |
| 490 | std::map<std::string, int32_t> getEndpointMapping() const { |
| 491 | return _parsedPart.getEndpointMapping(); |
| 492 | } |
| 493 |
| 494 | int getRemainingMilliseconds() const { |
| 495 | return _remainingMilliseconds; |
| 496 | } |
| 497 |
| 498 | std::vector<AudioStreamingPart::StreamingPartChannel> get10msPerChannel() { |
| 499 | if (_didReadToEnd) { |
| 500 | return {}; |
| 501 | } |
| 502 |
| 503 | for (const auto &update : _parsedPart.getChannelUpdates()) { |
| 504 | if (update.frameIndex == _frameIndex) { |
| 505 | updateCurrentMapping(update.ssrc, update.id); |
| 506 | } |
| 507 | } |
| 508 |
| 509 | auto readResult = _parsedPart.readPcm(_pcm10ms); |
| 510 | if (readResult.numSamples <= 0) { |
| 511 | _didReadToEnd = true; |
| 512 | return {}; |
| 513 | } |
| 514 |
| 515 | std::vector<AudioStreamingPart::StreamingPartChannel> resultChannels; |
| 516 | for (const auto ssrc : _allSsrcs) { |
| 517 | AudioStreamingPart::StreamingPartChannel emptyPart; |
| 518 | emptyPart.ssrc = ssrc; |
| 519 | resultChannels.push_back(emptyPart); |
| 520 | } |
| 521 |
| 522 | for (auto &channel : resultChannels) { |
| 523 | auto mappedChannelIndex = getCurrentMappedChannelIndex(channel.ssrc); |
| 524 |
| 525 | if (mappedChannelIndex) { |
| 526 | int sourceChannelIndex = mappedChannelIndex.value(); |
| 527 | for (int j = 0; j < readResult.numSamples; j++) { |
| 528 | channel.pcmData.push_back(_pcm10ms[sourceChannelIndex + j * readResult.numChannels]); |
| 529 | } |
| 530 | } else { |
| 531 | for (int j = 0; j < readResult.numSamples; j++) { |
| 532 | channel.pcmData.push_back(0); |
| 533 | } |
| 534 | } |
| 535 | } |
| 536 |
| 537 | _remainingMilliseconds -= 10; |
| 538 | if (_remainingMilliseconds < 0) { |
| 539 | _remainingMilliseconds = 0; |
| 540 | } |
| 541 | _frameIndex++; |
| 542 |
| 543 | return resultChannels; |
| 544 | } |
| 545 |
| 546 | private: |
| 547 | absl::optional<int> getCurrentMappedChannelIndex(uint32_t ssrc) { |
| 548 | for (const auto &it : _currentChannelMapping) { |
| 549 | if (it.ssrc == ssrc) { |
| 550 | return it.channelIndex; |
| 551 | } |
| 552 | } |
| 553 | return absl::nullopt; |
| 554 | } |
| 555 |
| 556 | void updateCurrentMapping(uint32_t ssrc, int channelIndex) { |
| 557 | for (int i = (int)_currentChannelMapping.size() - 1; i >= 0; i--) { |
| 558 | const auto &entry = _currentChannelMapping[i]; |
| 559 | if (entry.ssrc == ssrc && entry.channelIndex == channelIndex) { |
| 560 | return; |
| 561 | } else if (entry.ssrc == ssrc || entry.channelIndex == channelIndex) { |
| 562 | _currentChannelMapping.erase(_currentChannelMapping.begin() + i); |
| 563 | } |
| 564 | } |
| 565 | _currentChannelMapping.emplace_back(ssrc, channelIndex); |
| 566 | } |
| 567 |
| 568 | private: |
| 569 | AudioStreamingPartInternal _parsedPart; |
| 570 | std::set<uint32_t> _allSsrcs; |
| 571 |
| 572 | std::vector<int16_t> _pcm10ms; |
| 573 | std::vector<ChannelMapping> _currentChannelMapping; |
| 574 | int _frameIndex = 0; |
| 575 | int _remainingMilliseconds = 0; |
| 576 |
| 577 | bool _didReadToEnd = false; |
| 578 | }; |
| 579 |
| 580 | AudioStreamingPart::AudioStreamingPart(std::vector<uint8_t> &&data) { |
| 581 | if (!data.empty()) { |
| 582 | _state = new AudioStreamingPartState(std::move(data)); |
| 583 | } |
| 584 | } |
| 585 |
| 586 | AudioStreamingPart::~AudioStreamingPart() { |
| 587 | if (_state) { |
| 588 | delete _state; |
| 589 | } |
| 590 | } |
| 591 |
| 592 | std::map<std::string, int32_t> AudioStreamingPart::getEndpointMapping() const { |
| 593 | return _state ? _state->getEndpointMapping() : std::map<std::string, int32_t>(); |
| 594 | } |
| 595 |
| 596 | int AudioStreamingPart::getRemainingMilliseconds() const { |
| 597 | return _state ? _state->getRemainingMilliseconds() : 0; |
| 598 | } |
| 599 |
| 600 | std::vector<AudioStreamingPart::StreamingPartChannel> AudioStreamingPart::get10msPerChannel() { |
| 601 | return _state |
| 602 | ? _state->get10msPerChannel() |
| 603 | : std::vector<AudioStreamingPart::StreamingPartChannel>(); |
| 604 | } |
| 605 |
| 606 | } |
| 607 |