OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #import "RTCPeerConnectionInterface+Internal.h" | 44 #import "RTCPeerConnectionInterface+Internal.h" |
45 #import "RTCVideoCapturer+Internal.h" | 45 #import "RTCVideoCapturer+Internal.h" |
46 #import "RTCVideoSource+Internal.h" | 46 #import "RTCVideoSource+Internal.h" |
47 #import "RTCVideoTrack+Internal.h" | 47 #import "RTCVideoTrack+Internal.h" |
48 | 48 |
49 #include "talk/app/webrtc/audiotrack.h" | 49 #include "talk/app/webrtc/audiotrack.h" |
50 #include "talk/app/webrtc/mediastreaminterface.h" | 50 #include "talk/app/webrtc/mediastreaminterface.h" |
51 #include "talk/app/webrtc/peerconnectioninterface.h" | 51 #include "talk/app/webrtc/peerconnectioninterface.h" |
52 #include "talk/app/webrtc/videosourceinterface.h" | 52 #include "talk/app/webrtc/videosourceinterface.h" |
53 #include "talk/app/webrtc/videotrack.h" | 53 #include "talk/app/webrtc/videotrack.h" |
| 54 #include "talk/app/webrtc/objc/h264decoderfactory.h" |
| 55 #include "talk/app/webrtc/objc/h264encoderfactory.h" |
54 #include "webrtc/base/logging.h" | 56 #include "webrtc/base/logging.h" |
55 #include "webrtc/base/ssladapter.h" | 57 #include "webrtc/base/ssladapter.h" |
56 | 58 |
57 | |
58 @implementation RTCPeerConnectionFactory { | 59 @implementation RTCPeerConnectionFactory { |
59 rtc::scoped_ptr<rtc::Thread> _signalingThread; | 60 rtc::scoped_ptr<rtc::Thread> _signalingThread; |
60 rtc::scoped_ptr<rtc::Thread> _workerThread; | 61 rtc::scoped_ptr<rtc::Thread> _workerThread; |
61 } | 62 } |
62 | 63 |
63 @synthesize nativeFactory = _nativeFactory; | 64 @synthesize nativeFactory = _nativeFactory; |
64 | 65 |
65 + (void)initializeSSL { | 66 + (void)initializeSSL { |
66 BOOL initialized = rtc::InitializeSSL(); | 67 BOOL initialized = rtc::InitializeSSL(); |
67 NSAssert(initialized, @"Failed to initialize SSL library"); | 68 NSAssert(initialized, @"Failed to initialize SSL library"); |
68 } | 69 } |
69 | 70 |
70 + (void)deinitializeSSL { | 71 + (void)deinitializeSSL { |
71 BOOL deinitialized = rtc::CleanupSSL(); | 72 BOOL deinitialized = rtc::CleanupSSL(); |
72 NSAssert(deinitialized, @"Failed to deinitialize SSL library"); | 73 NSAssert(deinitialized, @"Failed to deinitialize SSL library"); |
73 } | 74 } |
74 | 75 |
75 - (id)init { | 76 - (id)init { |
76 if ((self = [super init])) { | 77 if ((self = [super init])) { |
77 _signalingThread.reset(new rtc::Thread()); | 78 _signalingThread.reset(new rtc::Thread()); |
78 BOOL result = _signalingThread->Start(); | 79 BOOL result = _signalingThread->Start(); |
79 NSAssert(result, @"Failed to start signaling thread."); | 80 NSAssert(result, @"Failed to start signaling thread."); |
80 _workerThread.reset(new rtc::Thread()); | 81 _workerThread.reset(new rtc::Thread()); |
81 result = _workerThread->Start(); | 82 result = _workerThread->Start(); |
82 NSAssert(result, @"Failed to start worker thread."); | 83 NSAssert(result, @"Failed to start worker thread."); |
| 84 |
| 85 rtc::scoped_ptr<webrtc::H264EncoderFactory> encoderFactory; |
| 86 rtc::scoped_ptr<webrtc::H264DecoderFactory> decoderFactory; |
| 87 #if defined(WEBRTC_OBJC_H264) |
| 88 encoderFactory.reset(new webrtc::H264EncoderFactory()); |
| 89 decoderFactory.reset(new webrtc::H264DecoderFactory()); |
| 90 #endif |
83 _nativeFactory = webrtc::CreatePeerConnectionFactory( | 91 _nativeFactory = webrtc::CreatePeerConnectionFactory( |
84 _signalingThread.get(), _workerThread.get(), NULL, NULL, NULL); | 92 _signalingThread.get(), _workerThread.get(), nullptr, |
| 93 encoderFactory.release(), decoderFactory.release()); |
85 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); | 94 NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!"); |
86 // Uncomment to get sensitive logs emitted (to stderr or logcat). | 95 // Uncomment to get sensitive logs emitted (to stderr or logcat). |
87 // rtc::LogMessage::LogToDebug(rtc::LS_SENSITIVE); | 96 // rtc::LogMessage::LogToDebug(rtc::LS_SENSITIVE); |
88 } | 97 } |
89 return self; | 98 return self; |
90 } | 99 } |
91 | 100 |
92 - (RTCPeerConnection *)peerConnectionWithConfiguration:(RTCConfiguration *)confi
guration | 101 - (RTCPeerConnection *)peerConnectionWithConfiguration:(RTCConfiguration *)confi
guration |
93 constraints:(RTCMediaConstraints *)co
nstraints | 102 constraints:(RTCMediaConstraints *)co
nstraints |
94 delegate:(id<RTCPeerConnectionDele
gate>)delegate { | 103 delegate:(id<RTCPeerConnectionDele
gate>)delegate { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 return [[RTCVideoTrack alloc] initWithMediaTrack:track]; | 148 return [[RTCVideoTrack alloc] initWithMediaTrack:track]; |
140 } | 149 } |
141 | 150 |
142 - (RTCAudioTrack*)audioTrackWithID:(NSString*)audioId { | 151 - (RTCAudioTrack*)audioTrackWithID:(NSString*)audioId { |
143 rtc::scoped_refptr<webrtc::AudioTrackInterface> track = | 152 rtc::scoped_refptr<webrtc::AudioTrackInterface> track = |
144 self.nativeFactory->CreateAudioTrack([audioId UTF8String], NULL); | 153 self.nativeFactory->CreateAudioTrack([audioId UTF8String], NULL); |
145 return [[RTCAudioTrack alloc] initWithMediaTrack:track]; | 154 return [[RTCAudioTrack alloc] initWithMediaTrack:track]; |
146 } | 155 } |
147 | 156 |
148 @end | 157 @end |
OLD | NEW |