Prepare for removal of PeerConnectionObserver::OnError.

Prepare for removal of constraints to PeerConnection::AddStream.

OnError has never been implemented and has been removed from the spec.
Also, constraints to PeerConnection::AddStream has also been removed from the spec and have never been implemented.

R=pbos@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/23319004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7605 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
perkj@webrtc.org 2014-11-04 11:31:29 +00:00
parent f37145f685
commit c2dd5ee2c0
23 changed files with 40 additions and 102 deletions

View File

@ -586,13 +586,6 @@ class PCOJava : public PeerConnectionObserver {
CHECK_EXCEPTION(jni()) << "error during CallVoidMethod";
}
virtual void OnError() OVERRIDE {
ScopedLocalRefFrame local_ref_frame(jni());
jmethodID m = GetMethodID(jni(), *j_observer_class_, "onError", "()V");
jni()->CallVoidMethod(*j_observer_global_, m);
CHECK_EXCEPTION(jni()) << "error during CallVoidMethod";
}
virtual void OnSignalingChange(
PeerConnectionInterface::SignalingState new_state) OVERRIDE {
ScopedLocalRefFrame local_ref_frame(jni());
@ -3144,12 +3137,9 @@ JOW(jboolean, PeerConnection_nativeAddIceCandidate)(
}
JOW(jboolean, PeerConnection_nativeAddLocalStream)(
JNIEnv* jni, jobject j_pc, jlong native_stream, jobject j_constraints) {
scoped_ptr<ConstraintsWrapper> constraints(
new ConstraintsWrapper(jni, j_constraints));
JNIEnv* jni, jobject j_pc, jlong native_stream) {
return ExtractNativePC(jni, j_pc)->AddStream(
reinterpret_cast<MediaStreamInterface*>(native_stream),
constraints.get());
reinterpret_cast<MediaStreamInterface*>(native_stream));
}
JOW(void, PeerConnection_nativeRemoveLocalStream)(

View File

@ -71,9 +71,6 @@ public class PeerConnection {
/** Triggered when a new ICE candidate has been found. */
public void onIceCandidate(IceCandidate candidate);
/** Triggered on any error. */
public void onError();
/** Triggered when media is received on a new stream from remote peer. */
public void onAddStream(MediaStream stream);
@ -147,9 +144,8 @@ public class PeerConnection {
candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp);
}
public boolean addStream(
MediaStream stream, MediaConstraints constraints) {
boolean ret = nativeAddLocalStream(stream.nativeStream, constraints);
public boolean addStream(MediaStream stream) {
boolean ret = nativeAddLocalStream(stream.nativeStream);
if (!ret) {
return false;
}
@ -194,8 +190,7 @@ public class PeerConnection {
private native boolean nativeAddIceCandidate(
String sdpMid, int sdpMLineIndex, String iceCandidateSdp);
private native boolean nativeAddLocalStream(
long nativeStream, MediaConstraints constraints);
private native boolean nativeAddLocalStream(long nativeStream);
private native void nativeRemoveLocalStream(long nativeStream);

View File

@ -117,11 +117,6 @@ public class PeerConnectionTest extends TestCase {
++expectedErrors;
}
@Override
public synchronized void onError() {
assertTrue(--expectedErrors >= 0);
}
public synchronized void expectSetSize() {
if (RENDER_TO_GUI) {
// When new frames are delivered to the GUI renderer we don't get
@ -489,7 +484,7 @@ public class PeerConnectionTest extends TestCase {
lMS.addTrack(videoTrack);
lMS.addTrack(factory.createAudioTrack(
audioTrackId, factory.createAudioSource(new MediaConstraints())));
pc.addStream(lMS, new MediaConstraints());
pc.addStream(lMS);
return new WeakReference<MediaStream>(lMS);
}

View File

@ -151,10 +151,8 @@ class RTCStatsObserver : public StatsObserver {
return self.peerConnection->AddIceCandidate(iceCandidate.get());
}
- (BOOL)addStream:(RTCMediaStream*)stream
constraints:(RTCMediaConstraints*)constraints {
BOOL ret = self.peerConnection->AddStream(stream.mediaStream,
constraints.constraints);
- (BOOL)addStream:(RTCMediaStream*)stream {
BOOL ret = self.peerConnection->AddStream(stream.mediaStream);
if (!ret) {
return NO;
}

View File

@ -41,8 +41,6 @@ class RTCPeerConnectionObserver : public PeerConnectionObserver {
RTCPeerConnectionObserver(RTCPeerConnection* peerConnection);
virtual ~RTCPeerConnectionObserver();
virtual void OnError() OVERRIDE;
// Triggered when the SignalingState changed.
virtual void OnSignalingChange(
PeerConnectionInterface::SignalingState new_state) OVERRIDE;

View File

@ -46,10 +46,6 @@ RTCPeerConnectionObserver::RTCPeerConnectionObserver(
RTCPeerConnectionObserver::~RTCPeerConnectionObserver() {
}
void RTCPeerConnectionObserver::OnError() {
[_peerConnection.delegate peerConnectionOnError:_peerConnection];
}
void RTCPeerConnectionObserver::OnSignalingChange(
PeerConnectionInterface::SignalingState new_state) {
RTCSignalingState state =

View File

@ -64,8 +64,7 @@
// Add a new MediaStream to be sent on this PeerConnection.
// Note that a SessionDescription negotiation is needed before the
// remote peer can receive the stream.
- (BOOL)addStream:(RTCMediaStream *)stream
constraints:(RTCMediaConstraints *)constraints;
- (BOOL)addStream:(RTCMediaStream *)stream;
// Remove a MediaStream from this PeerConnection.
// Note that a SessionDescription negotiation is need before the

View File

@ -38,9 +38,6 @@
// implemented to get messages from PeerConnection.
@protocol RTCPeerConnectionDelegate<NSObject>
// Triggered when there is an error.
- (void)peerConnectionOnError:(RTCPeerConnection *)peerConnection;
// Triggered when the SignalingState changed.
- (void)peerConnection:(RTCPeerConnection *)peerConnection
signalingStateChanged:(RTCSignalingState)stateChanged;

View File

@ -151,11 +151,6 @@
#pragma mark - RTCPeerConnectionDelegate methods
- (void)peerConnectionOnError:(RTCPeerConnection*)peerConnection {
NSLog(@"RTCPeerConnectionDelegate::onError");
NSAssert(--_expectedErrors >= 0, @"Unexpected error");
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
signalingStateChanged:(RTCSignalingState)stateChanged {
int expectedState = [self popFirstElementAsInt:_expectedSignalingChanges];

View File

@ -89,8 +89,7 @@
[localMediaStream addVideoTrack:videoTrack];
RTCAudioTrack* audioTrack = [factory audioTrackWithID:audioTrackID];
[localMediaStream addAudioTrack:audioTrack];
RTCMediaConstraints* constraints = [[RTCMediaConstraints alloc] init];
[pc addStream:localMediaStream constraints:constraints];
[pc addStream:localMediaStream];
return localMediaStream;
}

View File

@ -404,8 +404,7 @@ PeerConnection::remote_streams() {
return mediastream_signaling_->remote_streams();
}
bool PeerConnection::AddStream(MediaStreamInterface* local_stream,
const MediaConstraintsInterface* constraints) {
bool PeerConnection::AddStream(MediaStreamInterface* local_stream) {
if (IsClosed()) {
return false;
}
@ -413,7 +412,6 @@ bool PeerConnection::AddStream(MediaStreamInterface* local_stream,
local_stream))
return false;
// TODO(perkj): Implement support for MediaConstraints in AddStream.
if (!mediastream_signaling_->AddLocalStream(local_stream)) {
return false;
}

View File

@ -65,8 +65,7 @@ class PeerConnection : public PeerConnectionInterface,
PeerConnectionObserver* observer);
virtual rtc::scoped_refptr<StreamCollectionInterface> local_streams();
virtual rtc::scoped_refptr<StreamCollectionInterface> remote_streams();
virtual bool AddStream(MediaStreamInterface* local_stream,
const MediaConstraintsInterface* constraints);
virtual bool AddStream(MediaStreamInterface* local_stream);
virtual void RemoveStream(MediaStreamInterface* local_stream);
virtual rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(

View File

@ -179,7 +179,7 @@ class PeerConnectionTestClientBase
stream->AddTrack(CreateLocalVideoTrack(stream_label));
}
EXPECT_TRUE(peer_connection_->AddStream(stream, NULL));
EXPECT_TRUE(peer_connection_->AddStream(stream));
}
size_t NumberOfLocalMediaStreams() {
@ -426,7 +426,6 @@ class PeerConnectionTestClientBase
}
// PeerConnectionObserver callbacks.
virtual void OnError() {}
virtual void OnMessage(const std::string&) {}
virtual void OnSignalingMessage(const std::string& /*msg*/) {}
virtual void OnSignalingChange(

View File

@ -40,6 +40,7 @@
#include "webrtc/base/thread.h"
using webrtc::FakeVideoTrackRenderer;
using webrtc::DataChannelInterface;
using webrtc::MediaStreamInterface;
using webrtc::PeerConnectionFactoryInterface;
using webrtc::PeerConnectionInterface;
@ -83,13 +84,13 @@ static const char kTurnIceServerWithIPv6Address[] =
class NullPeerConnectionObserver : public PeerConnectionObserver {
public:
virtual void OnError() {}
virtual void OnMessage(const std::string& msg) {}
virtual void OnSignalingMessage(const std::string& msg) {}
virtual void OnSignalingChange(
PeerConnectionInterface::SignalingState new_state) {}
virtual void OnAddStream(MediaStreamInterface* stream) {}
virtual void OnRemoveStream(MediaStreamInterface* stream) {}
virtual void OnDataChannel(DataChannelInterface* data_channel) {}
virtual void OnRenegotiationNeeded() {}
virtual void OnIceConnectionChange(
PeerConnectionInterface::IceConnectionState new_state) {}

View File

@ -252,11 +252,17 @@ class PeerConnectionInterface : public rtc::RefCountInterface {
virtual rtc::scoped_refptr<StreamCollectionInterface>
remote_streams() = 0;
// Deprecated:
// TODO(perkj): Remove once its not used by Chrome.
virtual bool AddStream(MediaStreamInterface* stream,
const MediaConstraintsInterface* constraints) {
return AddStream(stream);
}
// Add a new MediaStream to be sent on this PeerConnection.
// Note that a SessionDescription negotiation is needed before the
// remote peer can receive the stream.
virtual bool AddStream(MediaStreamInterface* stream,
const MediaConstraintsInterface* constraints) = 0;
virtual bool AddStream(MediaStreamInterface* stream) = 0;
// Remove a MediaStream from this PeerConnection.
// Note that a SessionDescription negotiation is need before the
@ -344,7 +350,9 @@ class PeerConnectionObserver {
kIceState,
};
virtual void OnError() = 0;
// Deprecated.
// TODO(perkj): Remove once its not used by Chrome.
virtual void OnError() {}
// Triggered when the SignalingState changed.
virtual void OnSignalingChange(
@ -361,8 +369,7 @@ class PeerConnectionObserver {
virtual void OnRemoveStream(MediaStreamInterface* stream) = 0;
// Triggered when a remote peer open a data channel.
// TODO(perkj): Make pure virtual.
virtual void OnDataChannel(DataChannelInterface* data_channel) {}
virtual void OnDataChannel(DataChannelInterface* data_channel) = 0;
// Triggered when renegotiation is needed, for example the ICE has restarted.
virtual void OnRenegotiationNeeded() = 0;

View File

@ -132,7 +132,6 @@ class MockPeerConnectionObserver : public PeerConnectionObserver {
state_ = pc_->signaling_state();
}
}
virtual void OnError() {}
virtual void OnSignalingChange(
PeerConnectionInterface::SignalingState new_state) {
EXPECT_EQ(pc_->signaling_state(), new_state);
@ -320,7 +319,7 @@ class PeerConnectionInterfaceTest : public testing::Test {
scoped_refptr<VideoTrackInterface> video_track(
pc_factory_->CreateVideoTrack(label + "v0", video_source));
stream->AddTrack(video_track.get());
EXPECT_TRUE(pc_->AddStream(stream, NULL));
EXPECT_TRUE(pc_->AddStream(stream));
EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
observer_.renegotiation_needed_ = false;
}
@ -332,7 +331,7 @@ class PeerConnectionInterfaceTest : public testing::Test {
scoped_refptr<AudioTrackInterface> audio_track(
pc_factory_->CreateAudioTrack(label + "a0", NULL));
stream->AddTrack(audio_track.get());
EXPECT_TRUE(pc_->AddStream(stream, NULL));
EXPECT_TRUE(pc_->AddStream(stream));
EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
observer_.renegotiation_needed_ = false;
}
@ -350,7 +349,7 @@ class PeerConnectionInterfaceTest : public testing::Test {
scoped_refptr<VideoTrackInterface> video_track(
pc_factory_->CreateVideoTrack(video_track_label, NULL));
stream->AddTrack(video_track.get());
EXPECT_TRUE(pc_->AddStream(stream, NULL));
EXPECT_TRUE(pc_->AddStream(stream));
EXPECT_TRUE_WAIT(observer_.renegotiation_needed_, kTimeout);
observer_.renegotiation_needed_ = false;
}
@ -574,7 +573,7 @@ TEST_F(PeerConnectionInterfaceTest, AddStreams) {
pc_factory_->CreateAudioTrack(
kStreamLabel3, static_cast<AudioSourceInterface*>(NULL)));
stream->AddTrack(audio_track.get());
EXPECT_TRUE(pc_->AddStream(stream, NULL));
EXPECT_TRUE(pc_->AddStream(stream));
EXPECT_EQ(3u, pc_->local_streams()->count());
// Remove the third stream.
@ -1180,7 +1179,7 @@ TEST_F(PeerConnectionInterfaceTest, CloseAndTestMethods) {
pc_->Close();
pc_->RemoveStream(local_stream);
EXPECT_FALSE(pc_->AddStream(local_stream, NULL));
EXPECT_FALSE(pc_->AddStream(local_stream));
ASSERT_FALSE(local_stream->GetAudioTracks().empty());
rtc::scoped_refptr<webrtc::DtmfSenderInterface> dtmf_sender(

View File

@ -39,8 +39,7 @@ BEGIN_PROXY_MAP(PeerConnection)
local_streams)
PROXY_METHOD0(rtc::scoped_refptr<StreamCollectionInterface>,
remote_streams)
PROXY_METHOD2(bool, AddStream, MediaStreamInterface*,
const MediaConstraintsInterface*)
PROXY_METHOD1(bool, AddStream, MediaStreamInterface*)
PROXY_METHOD1(void, RemoveStream, MediaStreamInterface*)
PROXY_METHOD1(rtc::scoped_refptr<DtmfSenderInterface>,
CreateDtmfSender, AudioTrackInterface*)

View File

@ -253,7 +253,7 @@ void PeerConnectionTestWrapper::GetAndAddUserMedia(
bool video, const webrtc::FakeConstraints& video_constraints) {
rtc::scoped_refptr<webrtc::MediaStreamInterface> stream =
GetUserMedia(audio, audio_constraints, video, video_constraints);
EXPECT_TRUE(peer_connection_->AddStream(stream, NULL));
EXPECT_TRUE(peer_connection_->AddStream(stream));
}
rtc::scoped_refptr<webrtc::MediaStreamInterface>

View File

@ -57,7 +57,6 @@ class PeerConnectionTestWrapper
const webrtc::DataChannelInit& init);
// Implements PeerConnectionObserver.
virtual void OnError() {}
virtual void OnSignalingChange(
webrtc::PeerConnectionInterface::SignalingState new_state) {}
virtual void OnStateChange(

View File

@ -110,7 +110,7 @@ public class PeerConnectionClient {
if (videoConstraints != null) {
videoMediaStream = factory.createLocalMediaStream("ARDAMSVideo");
videoMediaStream.addTrack(createVideoTrack(useFrontFacingCamera));
pc.addStream(videoMediaStream, new MediaConstraints());
pc.addStream(videoMediaStream);
}
if (appRtcParameters.audioConstraints != null) {
@ -118,7 +118,7 @@ public class PeerConnectionClient {
lMS.addTrack(factory.createAudioTrack(
"ARDAMSa0",
factory.createAudioSource(appRtcParameters.audioConstraints)));
pc.addStream(lMS, new MediaConstraints());
pc.addStream(lMS);
}
}
@ -409,7 +409,7 @@ public class PeerConnectionClient {
useFrontFacingCamera = !useFrontFacingCamera;
VideoTrack newTrack = createVideoTrack(useFrontFacingCamera);
videoMediaStream.addTrack(newTrack);
pc.addStream(videoMediaStream, new MediaConstraints());
pc.addStream(videoMediaStream);
SessionDescription remoteDesc = pc.getRemoteDescription();
if (localSdp == null || remoteDesc == null) {
@ -440,11 +440,6 @@ public class PeerConnectionClient {
});
}
@Override
public void onError() {
reportError("PeerConnection error!");
}
@Override
public void onSignalingChange(
PeerConnection.SignalingState newState) {

View File

@ -170,7 +170,7 @@
#endif
[lms addAudioTrack:[self.peerConnectionFactory audioTrackWithID:@"ARDAMSa0"]];
[self.peerConnection addStream:lms constraints:constraints];
[self.peerConnection addStream:lms];
[self.logger logMessage:@"onICEServers - added local stream."];
}
@ -243,16 +243,6 @@
#pragma mark - RTCPeerConnectionDelegate
- (void)peerConnectionOnError:(RTCPeerConnection*)peerConnection {
dispatch_async(dispatch_get_main_queue(), ^{
NSString* message = @"PeerConnection error";
NSLog(@"%@", message);
NSAssert(NO, @"PeerConnection failed.");
[self.delegate connectionManager:self
didErrorWithMessage:message];
});
}
- (void)peerConnection:(RTCPeerConnection*)peerConnection
signalingStateChanged:(RTCSignalingState)stateChanged {
dispatch_async(dispatch_get_main_queue(), ^{

View File

@ -137,11 +137,6 @@ void Conductor::EnsureStreamingUI() {
// PeerConnectionObserver implementation.
//
void Conductor::OnError() {
LOG(LS_ERROR) << __FUNCTION__;
main_wnd_->QueueUIThreadCallback(PEER_CONNECTION_ERROR, NULL);
}
// Called when a remote stream is added
void Conductor::OnAddStream(webrtc::MediaStreamInterface* stream) {
LOG(INFO) << __FUNCTION__ << " " << stream->label();
@ -373,7 +368,7 @@ void Conductor::AddStreams() {
stream->AddTrack(audio_track);
stream->AddTrack(video_track);
if (!peer_connection_->AddStream(stream, NULL)) {
if (!peer_connection_->AddStream(stream)) {
LOG(LS_ERROR) << "Adding stream to PeerConnection failed";
}
typedef std::pair<std::string,
@ -440,10 +435,6 @@ void Conductor::UIThreadCallback(int msg_id, void* data) {
break;
}
case PEER_CONNECTION_ERROR:
main_wnd_->MessageBox("Error", "an unknown error occurred", true);
break;
case NEW_STREAM_ADDED: {
webrtc::MediaStreamInterface* stream =
reinterpret_cast<webrtc::MediaStreamInterface*>(

View File

@ -58,7 +58,6 @@ class Conductor
MEDIA_CHANNELS_INITIALIZED = 1,
PEER_CONNECTION_CLOSED,
SEND_MESSAGE_TO_PEER,
PEER_CONNECTION_ERROR,
NEW_STREAM_ADDED,
STREAM_REMOVED,
};
@ -80,11 +79,11 @@ class Conductor
//
// PeerConnectionObserver implementation.
//
virtual void OnError();
virtual void OnStateChange(
webrtc::PeerConnectionObserver::StateType state_changed) {}
virtual void OnAddStream(webrtc::MediaStreamInterface* stream);
virtual void OnRemoveStream(webrtc::MediaStreamInterface* stream);
virtual void OnDataChannel(webrtc::DataChannelInterface* channel) {}
virtual void OnRenegotiationNeeded() {}
virtual void OnIceChange() {}
virtual void OnIceCandidate(const webrtc::IceCandidateInterface* candidate);