Revert of Add the OnAddTrack callback for Objective-C wrapper. (patchset #7 id:240001 of https://codereview.webrtc.org/2513063003/ )

Reason for revert:
This CL breaks iOS AppRTCMobile. We don't have any automatic tests running on the bots yet, so please try AppRTCMobile locally before relanding.

Stack trace:
* thread #15: tid = 0x20e933, 0x0000000100488440 AppRTCMobile`webrtc::AudioRtpReceiver::OnFirstPacketReceived(this=0x0000000170156c60, channel=0x000000010511a600) + 48 at rtpreceiver.cc:133, name = 'Thread 0x0x10421b2a0', stop reason = EXC_BAD_ACCESS (code=1, address=0x1a1aac71979)
  * frame #0: 0x0000000100488440 AppRTCMobile`webrtc::AudioRtpReceiver::OnFirstPacketReceived(this=0x0000000170156c60, channel=0x000000010511a600) + 48 at rtpreceiver.cc:133
    frame #1: 0x000000010048a3f8 AppRTCMobile`void sigslot::_opaque_connection::emitter<webrtc::AudioRtpReceiver, cricket::BaseChannel*>(self=0x000000017424b380, args=0x000000010511a600) + 184 at sigslot.h:391
    frame #2: 0x00000001005a30ec AppRTCMobile`void sigslot::_opaque_connection::emit<cricket::BaseChannel*>(this=0x000000017424b380, args=0x000000010511a600) const + 56 at sigslot.h:381
    frame #3: 0x00000001005a3094 AppRTCMobile`sigslot::signal_with_thread_policy<sigslot::single_threaded, cricket::BaseChannel*>::emit(this=0x000000010511a678, args=0x000000010511a600) + 504 at sigslot.h:615
    frame #4: 0x000000010057ef5c AppRTCMobile`sigslot::signal_with_thread_policy<sigslot::single_threaded, cricket::BaseChannel*>::operator(this=0x000000010511a678, args=0x000000010511a600)(cricket::BaseChannel*) + 32 at sigslot.h:621
    frame #5: 0x000000010057ef00 AppRTCMobile`cricket::BaseChannel::OnMessage(this=0x000000010511a600, pmsg=0x000000016e676db0) + 600 at channel.cc:1494
    frame #6: 0x0000000100584a58 AppRTCMobile`cricket::VoiceChannel::OnMessage(this=0x000000010511a600, pmsg=0x000000016e676db0) + 152 at channel.cc:1909
    frame #7: 0x000000010017c0dc AppRTCMobile`rtc::MessageQueue::Dispatch(this=0x000000010421b2a0, pmsg=0x000000016e676db0) + 336 at messagequeue.cc:538
    frame #8: 0x00000001001d8efc AppRTCMobile`rtc::Thread::ProcessMessages(this=0x000000010421b2a0, cmsLoop=-1) + 228 at thread.cc:496
    frame #9: 0x00000001001d8e08 AppRTCMobile`rtc::Thread::Run(this=0x000000010421b2a0) + 28 at thread.cc:327
    frame #10: 0x00000001001d8b0c AppRTCMobile`rtc::Thread::PreRun(pv=0x000000017000f030) + 300 at thread.cc:316
    frame #11: 0x00000001843f1850 libsystem_pthread.dylib`_pthread_body + 240
    frame #12: 0x00000001843f1760 libsystem_pthread.dylib`_pthread_start + 284
    frame #13: 0x00000001843eed94 libsystem_pthread.dylib`thread_start + 4

Original issue's description:
> Add the OnAddTrack callback for Objective-C wrapper.
>
> Created an Obj-C wrapper for the callback OnAddTrack in this CL since it has been added to native C++ API
> The callback function is called when a track is signaled by remote side and a new RtpReceiver is created.
> The application can tell when tracks are added to the streams by listening to this callback.
>
> BUG=webrtc:6112
>
> Review-Url: https://codereview.webrtc.org/2513063003
> Cr-Commit-Position: refs/heads/master@{#16835}
> Committed: 633f6fe004

TBR=tkchin@webrtc.org,deadbeef@webrtc.org,zhihuang@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:6112

Review-Url: https://codereview.webrtc.org/2720753002
Cr-Commit-Position: refs/heads/master@{#16871}
This commit is contained in:
magjed
2017-02-27 07:04:25 -08:00
committed by Commit bot
parent a8ba195db5
commit 63bafd62f1
3 changed files with 3 additions and 60 deletions

View File

@ -49,12 +49,8 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver {
void OnIceCandidatesRemoved(
const std::vector<cricket::Candidate>& candidates) override;
void OnAddTrack(
rtc::scoped_refptr<RtpReceiverInterface> receiver,
const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) override;
private:
__weak RTCPeerConnection* peer_connection_;
__weak RTCPeerConnection *peer_connection_;
};
} // namespace webrtc
@ -106,11 +102,6 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver {
+ (webrtc::PeerConnectionInterface::StatsOutputLevel)
nativeStatsOutputLevelForLevel:(RTCStatsOutputLevel)level;
- (RTCMediaStream *)mediaStreamForNativeStream:
(rtc::scoped_refptr<webrtc::MediaStreamInterface>)stream;
- (void)removeNativeMediaStream:(rtc::scoped_refptr<webrtc::MediaStreamInterface>)stream;
@end
NS_ASSUME_NONNULL_END

View File

@ -27,7 +27,6 @@
#include "webrtc/api/jsepicecandidate.h"
#include "webrtc/base/checks.h"
#include "webrtc/sdk/objc/Framework/Classes/helpers.h"
NSString * const kRTCPeerConnectionErrorDomain =
@"org.webrtc.RTCPeerConnection";
@ -128,8 +127,9 @@ void PeerConnectionDelegateAdapter::OnSignalingChange(
void PeerConnectionDelegateAdapter::OnAddStream(
rtc::scoped_refptr<MediaStreamInterface> stream) {
RTCMediaStream *mediaStream =
[[RTCMediaStream alloc] initWithNativeMediaStream:stream];
RTCPeerConnection *peer_connection = peer_connection_;
RTCMediaStream *mediaStream = [peer_connection mediaStreamForNativeStream:stream];
[peer_connection.delegate peerConnection:peer_connection
didAddStream:mediaStream];
}
@ -141,7 +141,6 @@ void PeerConnectionDelegateAdapter::OnRemoveStream(
RTCPeerConnection *peer_connection = peer_connection_;
[peer_connection.delegate peerConnection:peer_connection
didRemoveStream:mediaStream];
[peer_connection removeNativeMediaStream:stream];
}
void PeerConnectionDelegateAdapter::OnDataChannel(
@ -201,28 +200,6 @@ void PeerConnectionDelegateAdapter::OnIceCandidatesRemoved(
didRemoveIceCandidates:ice_candidates];
}
void PeerConnectionDelegateAdapter::OnAddTrack(
rtc::scoped_refptr<RtpReceiverInterface> receiver,
const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) {
RTCRtpReceiver* rtpReceiver =
[[RTCRtpReceiver alloc] initWithNativeRtpReceiver:receiver];
NSMutableArray* mediaStreams =
[NSMutableArray arrayWithCapacity:streams.size()];
RTCPeerConnection* peer_connection = peer_connection_;
for (const auto stream : streams) {
RTCMediaStream* mediaStream =
[peer_connection mediaStreamForNativeStream:stream];
[mediaStreams addObject:mediaStream];
}
if ([peer_connection.delegate
respondsToSelector:@selector(peerConnection:didAddTrack:streams:)]) {
[peer_connection.delegate peerConnection:peer_connection
didAddTrack:rtpReceiver
streams:mediaStreams];
}
}
} // namespace webrtc
@ -232,7 +209,6 @@ void PeerConnectionDelegateAdapter::OnAddTrack(
rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection;
std::unique_ptr<webrtc::MediaConstraints> _nativeConstraints;
BOOL _hasStartedRtcEventLog;
NSMutableDictionary<NSString *, RTCMediaStream *> *_mediaStreamsByStreamId;
}
@synthesize delegate = _delegate;
@ -262,7 +238,6 @@ void PeerConnectionDelegateAdapter::OnAddTrack(
}
_localStreams = [[NSMutableArray alloc] init];
_delegate = delegate;
_mediaStreamsByStreamId = [NSMutableDictionary dictionary];
}
return self;
}
@ -613,21 +588,6 @@ void PeerConnectionDelegateAdapter::OnAddTrack(
}
}
- (RTCMediaStream *)mediaStreamForNativeStream:
(rtc::scoped_refptr<webrtc::MediaStreamInterface>)stream {
RTCMediaStream *mediaStream =
_mediaStreamsByStreamId[[NSString stringForStdString:stream->label()]];
if (!mediaStream) {
mediaStream = [[RTCMediaStream alloc] initWithNativeMediaStream:stream.get()];
_mediaStreamsByStreamId[[NSString stringForStdString:stream->label()]] = mediaStream;
}
return mediaStream;
}
- (void)removeNativeMediaStream:(rtc::scoped_refptr<webrtc::MediaStreamInterface>)stream {
[_mediaStreamsByStreamId removeObjectForKey:[NSString stringForStdString:stream->label()]];
}
- (rtc::scoped_refptr<webrtc::PeerConnectionInterface>)nativePeerConnection {
return _peerConnection;
}