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 = [
|
deps = [
|
||||||
"../api:libjingle_peerconnection_test_api",
|
"../api:libjingle_peerconnection_test_api",
|
||||||
"../api:video_frame_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",
|
||||||
"../media:rtc_media_base",
|
"../media:rtc_media_base",
|
||||||
"../modules/video_capture:video_capture_module",
|
"../modules/video_capture:video_capture_module",
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include <utility>
|
#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/test/fakeconstraints.h"
|
||||||
#include "api/videosourceproxy.h"
|
#include "api/videosourceproxy.h"
|
||||||
#include "media/engine/webrtcvideocapturerfactory.h"
|
#include "media/engine/webrtcvideocapturerfactory.h"
|
||||||
@ -91,7 +93,8 @@ bool SimplePeerConnection::InitializePeerConnection(const char** turn_urls,
|
|||||||
|
|
||||||
g_peer_connection_factory = webrtc::CreatePeerConnectionFactory(
|
g_peer_connection_factory = webrtc::CreatePeerConnectionFactory(
|
||||||
g_worker_thread.get(), g_worker_thread.get(), g_signaling_thread.get(),
|
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()) {
|
if (!g_peer_connection_factory.get()) {
|
||||||
DeletePeerConnection();
|
DeletePeerConnection();
|
||||||
@ -99,19 +102,19 @@ bool SimplePeerConnection::InitializePeerConnection(const char** turn_urls,
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_peer_count++;
|
g_peer_count++;
|
||||||
if (!CreatePeerConnection(turn_urls, no_of_urls, username, credential,
|
if (!CreatePeerConnection(turn_urls, no_of_urls, username, credential)) {
|
||||||
is_receiver)) {
|
|
||||||
DeletePeerConnection();
|
DeletePeerConnection();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mandatory_receive_ = is_receiver;
|
||||||
return peer_connection_.get() != nullptr;
|
return peer_connection_.get() != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SimplePeerConnection::CreatePeerConnection(const char** turn_urls,
|
bool SimplePeerConnection::CreatePeerConnection(const char** turn_urls,
|
||||||
const int no_of_urls,
|
const int no_of_urls,
|
||||||
const char* username,
|
const char* username,
|
||||||
const char* credential,
|
const char* credential) {
|
||||||
bool is_receiver) {
|
|
||||||
RTC_DCHECK(g_peer_connection_factory.get() != nullptr);
|
RTC_DCHECK(g_peer_connection_factory.get() != nullptr);
|
||||||
RTC_DCHECK(peer_connection_.get() == nullptr);
|
RTC_DCHECK(peer_connection_.get() == nullptr);
|
||||||
|
|
||||||
@ -148,11 +151,6 @@ bool SimplePeerConnection::CreatePeerConnection(const char** turn_urls,
|
|||||||
webrtc::FakeConstraints constraints;
|
webrtc::FakeConstraints constraints;
|
||||||
constraints.SetAllowDtlsSctpDataChannels();
|
constraints.SetAllowDtlsSctpDataChannels();
|
||||||
|
|
||||||
if (is_receiver) {
|
|
||||||
constraints.SetMandatoryReceiveAudio(true);
|
|
||||||
constraints.SetMandatoryReceiveVideo(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
peer_connection_ = g_peer_connection_factory->CreatePeerConnection(
|
peer_connection_ = g_peer_connection_factory->CreatePeerConnection(
|
||||||
config_, &constraints, nullptr, nullptr, this);
|
config_, &constraints, nullptr, nullptr, this);
|
||||||
|
|
||||||
@ -192,7 +190,12 @@ bool SimplePeerConnection::CreateOffer() {
|
|||||||
if (!peer_connection_.get())
|
if (!peer_connection_.get())
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +203,12 @@ bool SimplePeerConnection::CreateAnswer() {
|
|||||||
if (!peer_connection_.get())
|
if (!peer_connection_.get())
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,8 +429,8 @@ void SimplePeerConnection::AddStreams(bool audio_only) {
|
|||||||
RTC_DCHECK(texture_helper != nullptr)
|
RTC_DCHECK(texture_helper != nullptr)
|
||||||
<< "Cannot get the Surface Texture Helper.";
|
<< "Cannot get the Surface Texture Helper.";
|
||||||
|
|
||||||
rtc::scoped_refptr<AndroidVideoTrackSource> source(
|
rtc::scoped_refptr<webrtc::jni::AndroidVideoTrackSource> source(
|
||||||
new rtc::RefCountedObject<AndroidVideoTrackSource>(
|
new rtc::RefCountedObject<webrtc::jni::AndroidVideoTrackSource>(
|
||||||
g_signaling_thread.get(), env, texture_helper, false));
|
g_signaling_thread.get(), env, texture_helper, false));
|
||||||
rtc::scoped_refptr<webrtc::VideoTrackSourceProxy> proxy_source =
|
rtc::scoped_refptr<webrtc::VideoTrackSourceProxy> proxy_source =
|
||||||
webrtc::VideoTrackSourceProxy::Create(g_signaling_thread.get(),
|
webrtc::VideoTrackSourceProxy::Create(g_signaling_thread.get(),
|
||||||
|
@ -64,8 +64,7 @@ class SimplePeerConnection : public webrtc::PeerConnectionObserver,
|
|||||||
bool CreatePeerConnection(const char** turn_urls,
|
bool CreatePeerConnection(const char** turn_urls,
|
||||||
const int no_of_urls,
|
const int no_of_urls,
|
||||||
const char* username,
|
const char* username,
|
||||||
const char* credential,
|
const char* credential);
|
||||||
bool is_receiver);
|
|
||||||
void CloseDataChannel();
|
void CloseDataChannel();
|
||||||
std::unique_ptr<cricket::VideoCapturer> OpenVideoCaptureDevice();
|
std::unique_ptr<cricket::VideoCapturer> OpenVideoCaptureDevice();
|
||||||
void SetAudioControl();
|
void SetAudioControl();
|
||||||
@ -127,6 +126,7 @@ class SimplePeerConnection : public webrtc::PeerConnectionObserver,
|
|||||||
|
|
||||||
bool is_mute_audio_ = false;
|
bool is_mute_audio_ = false;
|
||||||
bool is_record_audio_ = false;
|
bool is_record_audio_ = false;
|
||||||
|
bool mandatory_receive_ = false;
|
||||||
|
|
||||||
// disallow copy-and-assign
|
// disallow copy-and-assign
|
||||||
SimplePeerConnection(const SimplePeerConnection&) = delete;
|
SimplePeerConnection(const SimplePeerConnection&) = delete;
|
||||||
|
Reference in New Issue
Block a user