Bug Fix: WebRTC Unity Plugin Audio One Way
When audio_only is on for the webrtc unity plugin, there is a bug that the audio from hologram cannot be heard at the remote side. Actually we found the audio is transmitted to the remote side, but the remote side wants video data also to playout everything. So without video data, the remote side will drop all the audio data. Thus, on the hologram (using webrtc unity plugin) side, we should not hook up a dummy camera, but instead we should use media constraint to request the remote side to send video data. This CL fixes the bug. Bug: webrtc:8555 Change-Id: I21ddda65185b645088aa4ac15f47b3f8ffad1873 Reviewed-on: https://webrtc-review.googlesource.com/24680 Commit-Queue: Qiang Chen <qiangchen@chromium.org> Reviewed-by: George Zhou <gyzhou@chromium.org> Cr-Commit-Position: refs/heads/master@{#21094}
This commit is contained in:
@ -657,6 +657,8 @@ if (is_win || is_android) {
|
||||
deps = [
|
||||
"../api:libjingle_peerconnection_test_api",
|
||||
"../api:video_frame_api",
|
||||
"../api/audio_codecs:builtin_audio_decoder_factory",
|
||||
"../api/audio_codecs:builtin_audio_encoder_factory",
|
||||
"../media:rtc_media",
|
||||
"../media:rtc_media_base",
|
||||
"../modules/video_capture:video_capture_module",
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||
#include "api/test/fakeconstraints.h"
|
||||
#include "api/videosourceproxy.h"
|
||||
#include "media/engine/webrtcvideocapturerfactory.h"
|
||||
@ -91,7 +93,8 @@ bool SimplePeerConnection::InitializePeerConnection(const char** turn_urls,
|
||||
|
||||
g_peer_connection_factory = webrtc::CreatePeerConnectionFactory(
|
||||
g_worker_thread.get(), g_worker_thread.get(), g_signaling_thread.get(),
|
||||
nullptr, nullptr, nullptr);
|
||||
nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
|
||||
webrtc::CreateBuiltinAudioDecoderFactory(), nullptr, nullptr);
|
||||
}
|
||||
if (!g_peer_connection_factory.get()) {
|
||||
DeletePeerConnection();
|
||||
@ -99,19 +102,19 @@ bool SimplePeerConnection::InitializePeerConnection(const char** turn_urls,
|
||||
}
|
||||
|
||||
g_peer_count++;
|
||||
if (!CreatePeerConnection(turn_urls, no_of_urls, username, credential,
|
||||
is_receiver)) {
|
||||
if (!CreatePeerConnection(turn_urls, no_of_urls, username, credential)) {
|
||||
DeletePeerConnection();
|
||||
return false;
|
||||
}
|
||||
|
||||
mandatory_receive_ = is_receiver;
|
||||
return peer_connection_.get() != nullptr;
|
||||
}
|
||||
|
||||
bool SimplePeerConnection::CreatePeerConnection(const char** turn_urls,
|
||||
const int no_of_urls,
|
||||
const char* username,
|
||||
const char* credential,
|
||||
bool is_receiver) {
|
||||
const char* credential) {
|
||||
RTC_DCHECK(g_peer_connection_factory.get() != nullptr);
|
||||
RTC_DCHECK(peer_connection_.get() == nullptr);
|
||||
|
||||
@ -148,11 +151,6 @@ bool SimplePeerConnection::CreatePeerConnection(const char** turn_urls,
|
||||
webrtc::FakeConstraints constraints;
|
||||
constraints.SetAllowDtlsSctpDataChannels();
|
||||
|
||||
if (is_receiver) {
|
||||
constraints.SetMandatoryReceiveAudio(true);
|
||||
constraints.SetMandatoryReceiveVideo(true);
|
||||
}
|
||||
|
||||
peer_connection_ = g_peer_connection_factory->CreatePeerConnection(
|
||||
config_, &constraints, nullptr, nullptr, this);
|
||||
|
||||
@ -192,7 +190,12 @@ bool SimplePeerConnection::CreateOffer() {
|
||||
if (!peer_connection_.get())
|
||||
return false;
|
||||
|
||||
peer_connection_->CreateOffer(this, nullptr);
|
||||
webrtc::FakeConstraints constraints;
|
||||
if (mandatory_receive_) {
|
||||
constraints.SetMandatoryReceiveAudio(true);
|
||||
constraints.SetMandatoryReceiveVideo(true);
|
||||
}
|
||||
peer_connection_->CreateOffer(this, &constraints);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -200,7 +203,12 @@ bool SimplePeerConnection::CreateAnswer() {
|
||||
if (!peer_connection_.get())
|
||||
return false;
|
||||
|
||||
peer_connection_->CreateAnswer(this, nullptr);
|
||||
webrtc::FakeConstraints constraints;
|
||||
if (mandatory_receive_) {
|
||||
constraints.SetMandatoryReceiveAudio(true);
|
||||
constraints.SetMandatoryReceiveVideo(true);
|
||||
}
|
||||
peer_connection_->CreateAnswer(this, &constraints);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -421,8 +429,8 @@ void SimplePeerConnection::AddStreams(bool audio_only) {
|
||||
RTC_DCHECK(texture_helper != nullptr)
|
||||
<< "Cannot get the Surface Texture Helper.";
|
||||
|
||||
rtc::scoped_refptr<AndroidVideoTrackSource> source(
|
||||
new rtc::RefCountedObject<AndroidVideoTrackSource>(
|
||||
rtc::scoped_refptr<webrtc::jni::AndroidVideoTrackSource> source(
|
||||
new rtc::RefCountedObject<webrtc::jni::AndroidVideoTrackSource>(
|
||||
g_signaling_thread.get(), env, texture_helper, false));
|
||||
rtc::scoped_refptr<webrtc::VideoTrackSourceProxy> proxy_source =
|
||||
webrtc::VideoTrackSourceProxy::Create(g_signaling_thread.get(),
|
||||
|
@ -64,8 +64,7 @@ class SimplePeerConnection : public webrtc::PeerConnectionObserver,
|
||||
bool CreatePeerConnection(const char** turn_urls,
|
||||
const int no_of_urls,
|
||||
const char* username,
|
||||
const char* credential,
|
||||
bool is_receiver);
|
||||
const char* credential);
|
||||
void CloseDataChannel();
|
||||
std::unique_ptr<cricket::VideoCapturer> OpenVideoCaptureDevice();
|
||||
void SetAudioControl();
|
||||
@ -127,6 +126,7 @@ class SimplePeerConnection : public webrtc::PeerConnectionObserver,
|
||||
|
||||
bool is_mute_audio_ = false;
|
||||
bool is_record_audio_ = false;
|
||||
bool mandatory_receive_ = false;
|
||||
|
||||
// disallow copy-and-assign
|
||||
SimplePeerConnection(const SimplePeerConnection&) = delete;
|
||||
|
Reference in New Issue
Block a user