magjed 63bafd62f1 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}
2017-02-27 15:04:25 +00:00

225 lines
7.8 KiB
Objective-C

/*
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#import <Foundation/Foundation.h>
#import <WebRTC/RTCMacros.h>
@class RTCConfiguration;
@class RTCDataChannel;
@class RTCDataChannelConfiguration;
@class RTCIceCandidate;
@class RTCMediaConstraints;
@class RTCMediaStream;
@class RTCMediaStreamTrack;
@class RTCPeerConnectionFactory;
@class RTCRtpReceiver;
@class RTCRtpSender;
@class RTCSessionDescription;
@class RTCLegacyStatsReport;
NS_ASSUME_NONNULL_BEGIN
extern NSString * const kRTCPeerConnectionErrorDomain;
extern int const kRTCSessionDescriptionErrorCode;
/** Represents the signaling state of the peer connection. */
typedef NS_ENUM(NSInteger, RTCSignalingState) {
RTCSignalingStateStable,
RTCSignalingStateHaveLocalOffer,
RTCSignalingStateHaveLocalPrAnswer,
RTCSignalingStateHaveRemoteOffer,
RTCSignalingStateHaveRemotePrAnswer,
// Not an actual state, represents the total number of states.
RTCSignalingStateClosed,
};
/** Represents the ice connection state of the peer connection. */
typedef NS_ENUM(NSInteger, RTCIceConnectionState) {
RTCIceConnectionStateNew,
RTCIceConnectionStateChecking,
RTCIceConnectionStateConnected,
RTCIceConnectionStateCompleted,
RTCIceConnectionStateFailed,
RTCIceConnectionStateDisconnected,
RTCIceConnectionStateClosed,
RTCIceConnectionStateCount,
};
/** Represents the ice gathering state of the peer connection. */
typedef NS_ENUM(NSInteger, RTCIceGatheringState) {
RTCIceGatheringStateNew,
RTCIceGatheringStateGathering,
RTCIceGatheringStateComplete,
};
/** Represents the stats output level. */
typedef NS_ENUM(NSInteger, RTCStatsOutputLevel) {
RTCStatsOutputLevelStandard,
RTCStatsOutputLevelDebug,
};
@class RTCPeerConnection;
RTC_EXPORT
@protocol RTCPeerConnectionDelegate <NSObject>
/** Called when the SignalingState changed. */
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didChangeSignalingState:(RTCSignalingState)stateChanged;
/** Called when media is received on a new stream from remote peer. */
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didAddStream:(RTCMediaStream *)stream;
/** Called when a remote peer closes a stream. */
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didRemoveStream:(RTCMediaStream *)stream;
/** Called when negotiation is needed, for example ICE has restarted. */
- (void)peerConnectionShouldNegotiate:(RTCPeerConnection *)peerConnection;
/** Called any time the IceConnectionState changes. */
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didChangeIceConnectionState:(RTCIceConnectionState)newState;
/** Called any time the IceGatheringState changes. */
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didChangeIceGatheringState:(RTCIceGatheringState)newState;
/** New ice candidate has been found. */
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didGenerateIceCandidate:(RTCIceCandidate *)candidate;
/** Called when a group of local Ice candidates have been removed. */
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didRemoveIceCandidates:(NSArray<RTCIceCandidate *> *)candidates;
/** New data channel has been opened. */
- (void)peerConnection:(RTCPeerConnection *)peerConnection
didOpenDataChannel:(RTCDataChannel *)dataChannel;
@end
RTC_EXPORT
@interface RTCPeerConnection : NSObject
/** The object that will be notifed about events such as state changes and
* streams being added or removed.
*/
@property(nonatomic, weak, nullable) id<RTCPeerConnectionDelegate> delegate;
@property(nonatomic, readonly) NSArray<RTCMediaStream *> *localStreams;
@property(nonatomic, readonly, nullable)
RTCSessionDescription *localDescription;
@property(nonatomic, readonly, nullable)
RTCSessionDescription *remoteDescription;
@property(nonatomic, readonly) RTCSignalingState signalingState;
@property(nonatomic, readonly) RTCIceConnectionState iceConnectionState;
@property(nonatomic, readonly) RTCIceGatheringState iceGatheringState;
/** Gets all RTCRtpSenders associated with this peer connection.
* Note: reading this property returns different instances of RTCRtpSender.
* Use isEqual: instead of == to compare RTCRtpSender instances.
*/
@property(nonatomic, readonly) NSArray<RTCRtpSender *> *senders;
/** Gets all RTCRtpReceivers associated with this peer connection.
* Note: reading this property returns different instances of RTCRtpReceiver.
* Use isEqual: instead of == to compare RTCRtpReceiver instances.
*/
@property(nonatomic, readonly) NSArray<RTCRtpReceiver *> *receivers;
- (instancetype)init NS_UNAVAILABLE;
/** Sets the PeerConnection's global configuration to |configuration|.
* Any changes to STUN/TURN servers or ICE candidate policy will affect the
* next gathering phase, and cause the next call to createOffer to generate
* new ICE credentials. Note that the BUNDLE and RTCP-multiplexing policies
* cannot be changed with this method.
*/
- (BOOL)setConfiguration:(RTCConfiguration *)configuration;
/** Terminate all media and close the transport. */
- (void)close;
/** Provide a remote candidate to the ICE Agent. */
- (void)addIceCandidate:(RTCIceCandidate *)candidate;
/** Remove a group of remote candidates from the ICE Agent. */
- (void)removeIceCandidates:(NSArray<RTCIceCandidate *> *)candidates;
/** Add a new media stream to be sent on this peer connection. */
- (void)addStream:(RTCMediaStream *)stream;
/** Remove the given media stream from this peer connection. */
- (void)removeStream:(RTCMediaStream *)stream;
/** Generate an SDP offer. */
- (void)offerForConstraints:(RTCMediaConstraints *)constraints
completionHandler:(nullable void (^)
(RTCSessionDescription * _Nullable sdp,
NSError * _Nullable error))completionHandler;
/** Generate an SDP answer. */
- (void)answerForConstraints:(RTCMediaConstraints *)constraints
completionHandler:(nullable void (^)
(RTCSessionDescription * _Nullable sdp,
NSError * _Nullable error))completionHandler;
/** Apply the supplied RTCSessionDescription as the local description. */
- (void)setLocalDescription:(RTCSessionDescription *)sdp
completionHandler:
(nullable void (^)(NSError * _Nullable error))completionHandler;
/** Apply the supplied RTCSessionDescription as the remote description. */
- (void)setRemoteDescription:(RTCSessionDescription *)sdp
completionHandler:
(nullable void (^)(NSError * _Nullable error))completionHandler;
/** Start or stop recording an Rtc EventLog. */
- (BOOL)startRtcEventLogWithFilePath:(NSString *)filePath
maxSizeInBytes:(int64_t)maxSizeInBytes;
- (void)stopRtcEventLog;
@end
@interface RTCPeerConnection (Media)
/**
* Create an RTCRtpSender with the specified kind and media stream ID.
* See RTCMediaStreamTrack.h for available kinds.
*/
- (RTCRtpSender *)senderWithKind:(NSString *)kind streamId:(NSString *)streamId;
@end
@interface RTCPeerConnection (DataChannel)
/** Create a new data channel with the given label and configuration. */
- (RTCDataChannel *)dataChannelForLabel:(NSString *)label
configuration:(RTCDataChannelConfiguration *)configuration;
@end
@interface RTCPeerConnection (Stats)
/** Gather stats for the given RTCMediaStreamTrack. If |mediaStreamTrack| is nil
* statistics are gathered for all tracks.
*/
- (void)statsForTrack:
(nullable RTCMediaStreamTrack *)mediaStreamTrack
statsOutputLevel:(RTCStatsOutputLevel)statsOutputLevel
completionHandler:
(nullable void (^)(NSArray<RTCLegacyStatsReport *> *stats))completionHandler;
@end
NS_ASSUME_NONNULL_END