OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 shared_->channel_manager().DestroyChannel(channel); | 461 shared_->channel_manager().DestroyChannel(channel); |
462 if (StopSend() != 0) { | 462 if (StopSend() != 0) { |
463 return -1; | 463 return -1; |
464 } | 464 } |
465 if (StopPlayout() != 0) { | 465 if (StopPlayout() != 0) { |
466 return -1; | 466 return -1; |
467 } | 467 } |
468 return 0; | 468 return 0; |
469 } | 469 } |
470 | 470 |
471 int VoEBaseImpl::StartReceive(int channel) { | |
472 rtc::CritScope cs(shared_->crit_sec()); | |
473 if (!shared_->statistics().Initialized()) { | |
474 shared_->SetLastError(VE_NOT_INITED, kTraceError); | |
475 return -1; | |
476 } | |
477 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); | |
478 voe::Channel* channelPtr = ch.channel(); | |
479 if (channelPtr == nullptr) { | |
480 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | |
481 "StartReceive() failed to locate channel"); | |
482 return -1; | |
483 } | |
484 return 0; | |
485 } | |
486 | |
487 int VoEBaseImpl::StartPlayout(int channel) { | 471 int VoEBaseImpl::StartPlayout(int channel) { |
488 rtc::CritScope cs(shared_->crit_sec()); | 472 rtc::CritScope cs(shared_->crit_sec()); |
489 if (!shared_->statistics().Initialized()) { | 473 if (!shared_->statistics().Initialized()) { |
490 shared_->SetLastError(VE_NOT_INITED, kTraceError); | 474 shared_->SetLastError(VE_NOT_INITED, kTraceError); |
491 return -1; | 475 return -1; |
492 } | 476 } |
493 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); | 477 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); |
494 voe::Channel* channelPtr = ch.channel(); | 478 voe::Channel* channelPtr = ch.channel(); |
495 if (channelPtr == nullptr) { | 479 if (channelPtr == nullptr) { |
496 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 480 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 voe::Channel* channelPtr = ch.channel(); | 546 voe::Channel* channelPtr = ch.channel(); |
563 if (channelPtr == nullptr) { | 547 if (channelPtr == nullptr) { |
564 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 548 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
565 "StopSend() failed to locate channel"); | 549 "StopSend() failed to locate channel"); |
566 return -1; | 550 return -1; |
567 } | 551 } |
568 channelPtr->StopSend(); | 552 channelPtr->StopSend(); |
569 return StopSend(); | 553 return StopSend(); |
570 } | 554 } |
571 | 555 |
572 int VoEBaseImpl::GetVersion(char version[1024]) { | |
573 if (version == nullptr) { | |
574 shared_->SetLastError(VE_INVALID_ARGUMENT, kTraceError); | |
575 return -1; | |
576 } | |
577 | |
578 std::string versionString = VoiceEngine::GetVersionString(); | |
579 RTC_DCHECK_GT(1024, versionString.size() + 1); | |
580 char* end = std::copy(versionString.cbegin(), versionString.cend(), version); | |
581 end[0] = '\n'; | |
582 end[1] = '\0'; | |
583 return 0; | |
584 } | |
585 | |
586 int VoEBaseImpl::LastError() { return (shared_->statistics().LastError()); } | |
587 | |
588 int32_t VoEBaseImpl::StartPlayout() { | 556 int32_t VoEBaseImpl::StartPlayout() { |
589 if (!shared_->audio_device()->Playing()) { | 557 if (!shared_->audio_device()->Playing()) { |
590 if (shared_->audio_device()->InitPlayout() != 0) { | 558 if (shared_->audio_device()->InitPlayout() != 0) { |
591 LOG_F(LS_ERROR) << "Failed to initialize playout"; | 559 LOG_F(LS_ERROR) << "Failed to initialize playout"; |
592 return -1; | 560 return -1; |
593 } | 561 } |
594 if (shared_->audio_device()->StartPlayout() != 0) { | 562 if (shared_->audio_device()->StartPlayout() != 0) { |
595 LOG_F(LS_ERROR) << "Failed to start playout"; | 563 LOG_F(LS_ERROR) << "Failed to start playout"; |
596 return -1; | 564 return -1; |
597 } | 565 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 assert(sample_rate == audioFrame_.sample_rate_hz_); | 677 assert(sample_rate == audioFrame_.sample_rate_hz_); |
710 | 678 |
711 // Deliver audio (PCM) samples to the ADM | 679 // Deliver audio (PCM) samples to the ADM |
712 memcpy(audio_data, audioFrame_.data(), | 680 memcpy(audio_data, audioFrame_.data(), |
713 sizeof(int16_t) * number_of_frames * number_of_channels); | 681 sizeof(int16_t) * number_of_frames * number_of_channels); |
714 | 682 |
715 *elapsed_time_ms = audioFrame_.elapsed_time_ms_; | 683 *elapsed_time_ms = audioFrame_.elapsed_time_ms_; |
716 *ntp_time_ms = audioFrame_.ntp_time_ms_; | 684 *ntp_time_ms = audioFrame_.ntp_time_ms_; |
717 } | 685 } |
718 | 686 |
719 int VoEBaseImpl::AssociateSendChannel(int channel, | |
720 int accociate_send_channel) { | |
721 rtc::CritScope cs(shared_->crit_sec()); | |
722 | |
723 if (!shared_->statistics().Initialized()) { | |
724 shared_->SetLastError(VE_NOT_INITED, kTraceError); | |
725 return -1; | |
726 } | |
727 | |
728 voe::ChannelOwner ch = shared_->channel_manager().GetChannel(channel); | |
729 voe::Channel* channel_ptr = ch.channel(); | |
730 if (channel_ptr == NULL) { | |
731 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | |
732 "AssociateSendChannel() failed to locate channel"); | |
733 return -1; | |
734 } | |
735 | |
736 ch = shared_->channel_manager().GetChannel(accociate_send_channel); | |
737 voe::Channel* accociate_send_channel_ptr = ch.channel(); | |
738 if (accociate_send_channel_ptr == NULL) { | |
739 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | |
740 "AssociateSendChannel() failed to locate accociate_send_channel"); | |
741 return -1; | |
742 } | |
743 | |
744 channel_ptr->set_associate_send_channel(ch); | |
745 return 0; | |
746 } | |
747 | |
748 } // namespace webrtc | 687 } // namespace webrtc |
OLD | NEW |