Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: talk/app/webrtc/mediastreamhandler.h

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: google::int32 Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 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 30 matching lines...) Expand all
41 #include "talk/app/webrtc/peerconnectioninterface.h" 41 #include "talk/app/webrtc/peerconnectioninterface.h"
42 #include "talk/media/base/audiorenderer.h" 42 #include "talk/media/base/audiorenderer.h"
43 #include "webrtc/base/thread.h" 43 #include "webrtc/base/thread.h"
44 44
45 namespace webrtc { 45 namespace webrtc {
46 46
47 // TrackHandler listen to events on a MediaStreamTrackInterface that is 47 // TrackHandler listen to events on a MediaStreamTrackInterface that is
48 // connected to a certain PeerConnection. 48 // connected to a certain PeerConnection.
49 class TrackHandler : public ObserverInterface { 49 class TrackHandler : public ObserverInterface {
50 public: 50 public:
51 TrackHandler(MediaStreamTrackInterface* track, uint32 ssrc); 51 TrackHandler(MediaStreamTrackInterface* track, uint32_t ssrc);
52 virtual ~TrackHandler(); 52 virtual ~TrackHandler();
53 virtual void OnChanged(); 53 virtual void OnChanged();
54 // Stop using |track_| on this PeerConnection. 54 // Stop using |track_| on this PeerConnection.
55 virtual void Stop() = 0; 55 virtual void Stop() = 0;
56 56
57 MediaStreamTrackInterface* track() { return track_; } 57 MediaStreamTrackInterface* track() { return track_; }
58 uint32 ssrc() const { return ssrc_; } 58 uint32_t ssrc() const { return ssrc_; }
59 59
60 protected: 60 protected:
61 virtual void OnStateChanged() = 0; 61 virtual void OnStateChanged() = 0;
62 virtual void OnEnabledChanged() = 0; 62 virtual void OnEnabledChanged() = 0;
63 63
64 private: 64 private:
65 rtc::scoped_refptr<MediaStreamTrackInterface> track_; 65 rtc::scoped_refptr<MediaStreamTrackInterface> track_;
66 uint32 ssrc_; 66 uint32_t ssrc_;
67 MediaStreamTrackInterface::TrackState state_; 67 MediaStreamTrackInterface::TrackState state_;
68 bool enabled_; 68 bool enabled_;
69 }; 69 };
70 70
71 // LocalAudioSinkAdapter receives data callback as a sink to the local 71 // LocalAudioSinkAdapter receives data callback as a sink to the local
72 // AudioTrack, and passes the data to the sink of AudioRenderer. 72 // AudioTrack, and passes the data to the sink of AudioRenderer.
73 class LocalAudioSinkAdapter : public AudioTrackSinkInterface, 73 class LocalAudioSinkAdapter : public AudioTrackSinkInterface,
74 public cricket::AudioRenderer { 74 public cricket::AudioRenderer {
75 public: 75 public:
76 LocalAudioSinkAdapter(); 76 LocalAudioSinkAdapter();
(...skipping 14 matching lines...) Expand all
91 // Critical section protecting |sink_|. 91 // Critical section protecting |sink_|.
92 rtc::CriticalSection lock_; 92 rtc::CriticalSection lock_;
93 }; 93 };
94 94
95 // LocalAudioTrackHandler listen to events on a local AudioTrack instance 95 // LocalAudioTrackHandler listen to events on a local AudioTrack instance
96 // connected to a PeerConnection and orders the |provider| to executes the 96 // connected to a PeerConnection and orders the |provider| to executes the
97 // requested change. 97 // requested change.
98 class LocalAudioTrackHandler : public TrackHandler { 98 class LocalAudioTrackHandler : public TrackHandler {
99 public: 99 public:
100 LocalAudioTrackHandler(AudioTrackInterface* track, 100 LocalAudioTrackHandler(AudioTrackInterface* track,
101 uint32 ssrc, 101 uint32_t ssrc,
102 AudioProviderInterface* provider); 102 AudioProviderInterface* provider);
103 virtual ~LocalAudioTrackHandler(); 103 virtual ~LocalAudioTrackHandler();
104 104
105 void Stop() override; 105 void Stop() override;
106 106
107 protected: 107 protected:
108 void OnStateChanged() override; 108 void OnStateChanged() override;
109 void OnEnabledChanged() override; 109 void OnEnabledChanged() override;
110 110
111 private: 111 private:
112 AudioTrackInterface* audio_track_; 112 AudioTrackInterface* audio_track_;
113 AudioProviderInterface* provider_; 113 AudioProviderInterface* provider_;
114 114
115 // Used to pass the data callback from the |audio_track_| to the other 115 // Used to pass the data callback from the |audio_track_| to the other
116 // end of cricket::AudioRenderer. 116 // end of cricket::AudioRenderer.
117 rtc::scoped_ptr<LocalAudioSinkAdapter> sink_adapter_; 117 rtc::scoped_ptr<LocalAudioSinkAdapter> sink_adapter_;
118 }; 118 };
119 119
120 // RemoteAudioTrackHandler listen to events on a remote AudioTrack instance 120 // RemoteAudioTrackHandler listen to events on a remote AudioTrack instance
121 // connected to a PeerConnection and orders the |provider| to executes the 121 // connected to a PeerConnection and orders the |provider| to executes the
122 // requested change. 122 // requested change.
123 class RemoteAudioTrackHandler : public AudioSourceInterface::AudioObserver, 123 class RemoteAudioTrackHandler : public AudioSourceInterface::AudioObserver,
124 public TrackHandler { 124 public TrackHandler {
125 public: 125 public:
126 RemoteAudioTrackHandler(AudioTrackInterface* track, 126 RemoteAudioTrackHandler(AudioTrackInterface* track,
127 uint32 ssrc, 127 uint32_t ssrc,
128 AudioProviderInterface* provider); 128 AudioProviderInterface* provider);
129 virtual ~RemoteAudioTrackHandler(); 129 virtual ~RemoteAudioTrackHandler();
130 void Stop() override; 130 void Stop() override;
131 131
132 protected: 132 protected:
133 void OnStateChanged() override; 133 void OnStateChanged() override;
134 void OnEnabledChanged() override; 134 void OnEnabledChanged() override;
135 135
136 private: 136 private:
137 // AudioSourceInterface::AudioObserver implementation. 137 // AudioSourceInterface::AudioObserver implementation.
138 void OnSetVolume(double volume) override; 138 void OnSetVolume(double volume) override;
139 139
140 AudioTrackInterface* audio_track_; 140 AudioTrackInterface* audio_track_;
141 AudioProviderInterface* provider_; 141 AudioProviderInterface* provider_;
142 }; 142 };
143 143
144 // LocalVideoTrackHandler listen to events on a local VideoTrack instance 144 // LocalVideoTrackHandler listen to events on a local VideoTrack instance
145 // connected to a PeerConnection and orders the |provider| to executes the 145 // connected to a PeerConnection and orders the |provider| to executes the
146 // requested change. 146 // requested change.
147 class LocalVideoTrackHandler : public TrackHandler { 147 class LocalVideoTrackHandler : public TrackHandler {
148 public: 148 public:
149 LocalVideoTrackHandler(VideoTrackInterface* track, 149 LocalVideoTrackHandler(VideoTrackInterface* track,
150 uint32 ssrc, 150 uint32_t ssrc,
151 VideoProviderInterface* provider); 151 VideoProviderInterface* provider);
152 virtual ~LocalVideoTrackHandler(); 152 virtual ~LocalVideoTrackHandler();
153 void Stop() override; 153 void Stop() override;
154 154
155 protected: 155 protected:
156 void OnStateChanged() override; 156 void OnStateChanged() override;
157 void OnEnabledChanged() override; 157 void OnEnabledChanged() override;
158 158
159 private: 159 private:
160 VideoTrackInterface* local_video_track_; 160 VideoTrackInterface* local_video_track_;
161 VideoProviderInterface* provider_; 161 VideoProviderInterface* provider_;
162 }; 162 };
163 163
164 // RemoteVideoTrackHandler listen to events on a remote VideoTrack instance 164 // RemoteVideoTrackHandler listen to events on a remote VideoTrack instance
165 // connected to a PeerConnection and orders the |provider| to execute 165 // connected to a PeerConnection and orders the |provider| to execute
166 // requested changes. 166 // requested changes.
167 class RemoteVideoTrackHandler : public TrackHandler { 167 class RemoteVideoTrackHandler : public TrackHandler {
168 public: 168 public:
169 RemoteVideoTrackHandler(VideoTrackInterface* track, 169 RemoteVideoTrackHandler(VideoTrackInterface* track,
170 uint32 ssrc, 170 uint32_t ssrc,
171 VideoProviderInterface* provider); 171 VideoProviderInterface* provider);
172 virtual ~RemoteVideoTrackHandler(); 172 virtual ~RemoteVideoTrackHandler();
173 void Stop() override; 173 void Stop() override;
174 174
175 protected: 175 protected:
176 void OnStateChanged() override; 176 void OnStateChanged() override;
177 void OnEnabledChanged() override; 177 void OnEnabledChanged() override;
178 178
179 private: 179 private:
180 VideoTrackInterface* remote_video_track_; 180 VideoTrackInterface* remote_video_track_;
181 VideoProviderInterface* provider_; 181 VideoProviderInterface* provider_;
182 }; 182 };
183 183
184 class MediaStreamHandler : public ObserverInterface { 184 class MediaStreamHandler : public ObserverInterface {
185 public: 185 public:
186 MediaStreamHandler(MediaStreamInterface* stream, 186 MediaStreamHandler(MediaStreamInterface* stream,
187 AudioProviderInterface* audio_provider, 187 AudioProviderInterface* audio_provider,
188 VideoProviderInterface* video_provider); 188 VideoProviderInterface* video_provider);
189 ~MediaStreamHandler(); 189 ~MediaStreamHandler();
190 MediaStreamInterface* stream(); 190 MediaStreamInterface* stream();
191 void Stop(); 191 void Stop();
192 192
193 virtual void AddAudioTrack(AudioTrackInterface* audio_track, uint32 ssrc) = 0; 193 virtual void AddAudioTrack(AudioTrackInterface* audio_track,
194 virtual void AddVideoTrack(VideoTrackInterface* video_track, uint32 ssrc) = 0; 194 uint32_t ssrc) = 0;
195 virtual void AddVideoTrack(VideoTrackInterface* video_track,
196 uint32_t ssrc) = 0;
195 197
196 virtual void RemoveTrack(MediaStreamTrackInterface* track); 198 virtual void RemoveTrack(MediaStreamTrackInterface* track);
197 void OnChanged() override; 199 void OnChanged() override;
198 200
199 protected: 201 protected:
200 TrackHandler* FindTrackHandler(MediaStreamTrackInterface* track); 202 TrackHandler* FindTrackHandler(MediaStreamTrackInterface* track);
201 rtc::scoped_refptr<MediaStreamInterface> stream_; 203 rtc::scoped_refptr<MediaStreamInterface> stream_;
202 AudioProviderInterface* audio_provider_; 204 AudioProviderInterface* audio_provider_;
203 VideoProviderInterface* video_provider_; 205 VideoProviderInterface* video_provider_;
204 typedef std::vector<TrackHandler*> TrackHandlers; 206 typedef std::vector<TrackHandler*> TrackHandlers;
205 TrackHandlers track_handlers_; 207 TrackHandlers track_handlers_;
206 }; 208 };
207 209
208 class LocalMediaStreamHandler : public MediaStreamHandler { 210 class LocalMediaStreamHandler : public MediaStreamHandler {
209 public: 211 public:
210 LocalMediaStreamHandler(MediaStreamInterface* stream, 212 LocalMediaStreamHandler(MediaStreamInterface* stream,
211 AudioProviderInterface* audio_provider, 213 AudioProviderInterface* audio_provider,
212 VideoProviderInterface* video_provider); 214 VideoProviderInterface* video_provider);
213 ~LocalMediaStreamHandler(); 215 ~LocalMediaStreamHandler();
214 216
215 void AddAudioTrack(AudioTrackInterface* audio_track, uint32 ssrc) override; 217 void AddAudioTrack(AudioTrackInterface* audio_track, uint32_t ssrc) override;
216 void AddVideoTrack(VideoTrackInterface* video_track, uint32 ssrc) override; 218 void AddVideoTrack(VideoTrackInterface* video_track, uint32_t ssrc) override;
217 }; 219 };
218 220
219 class RemoteMediaStreamHandler : public MediaStreamHandler { 221 class RemoteMediaStreamHandler : public MediaStreamHandler {
220 public: 222 public:
221 RemoteMediaStreamHandler(MediaStreamInterface* stream, 223 RemoteMediaStreamHandler(MediaStreamInterface* stream,
222 AudioProviderInterface* audio_provider, 224 AudioProviderInterface* audio_provider,
223 VideoProviderInterface* video_provider); 225 VideoProviderInterface* video_provider);
224 ~RemoteMediaStreamHandler(); 226 ~RemoteMediaStreamHandler();
225 void AddAudioTrack(AudioTrackInterface* audio_track, uint32 ssrc) override; 227 void AddAudioTrack(AudioTrackInterface* audio_track, uint32_t ssrc) override;
226 void AddVideoTrack(VideoTrackInterface* video_track, uint32 ssrc) override; 228 void AddVideoTrack(VideoTrackInterface* video_track, uint32_t ssrc) override;
227 }; 229 };
228 230
229 // Container for MediaStreamHandlers of currently known local and remote 231 // Container for MediaStreamHandlers of currently known local and remote
230 // MediaStreams. 232 // MediaStreams.
231 class MediaStreamHandlerContainer { 233 class MediaStreamHandlerContainer {
232 public: 234 public:
233 MediaStreamHandlerContainer(AudioProviderInterface* audio_provider, 235 MediaStreamHandlerContainer(AudioProviderInterface* audio_provider,
234 VideoProviderInterface* video_provider); 236 VideoProviderInterface* video_provider);
235 ~MediaStreamHandlerContainer(); 237 ~MediaStreamHandlerContainer();
236 238
237 // Notify all referenced objects that MediaStreamHandlerContainer will be 239 // Notify all referenced objects that MediaStreamHandlerContainer will be
238 // destroyed. This method must be called prior to the dtor and prior to the 240 // destroyed. This method must be called prior to the dtor and prior to the
239 // |audio_provider| and |video_provider| is destroyed. 241 // |audio_provider| and |video_provider| is destroyed.
240 void TearDown(); 242 void TearDown();
241 243
242 // Remove all TrackHandlers for tracks in |stream| and make sure 244 // Remove all TrackHandlers for tracks in |stream| and make sure
243 // the audio_provider and video_provider is notified that the tracks has been 245 // the audio_provider and video_provider is notified that the tracks has been
244 // removed. 246 // removed.
245 void RemoveRemoteStream(MediaStreamInterface* stream); 247 void RemoveRemoteStream(MediaStreamInterface* stream);
246 248
247 // Create a RemoteAudioTrackHandler and associate |audio_track| with |ssrc|. 249 // Create a RemoteAudioTrackHandler and associate |audio_track| with |ssrc|.
248 void AddRemoteAudioTrack(MediaStreamInterface* stream, 250 void AddRemoteAudioTrack(MediaStreamInterface* stream,
249 AudioTrackInterface* audio_track, 251 AudioTrackInterface* audio_track,
250 uint32 ssrc); 252 uint32_t ssrc);
251 // Create a RemoteVideoTrackHandler and associate |video_track| with |ssrc|. 253 // Create a RemoteVideoTrackHandler and associate |video_track| with |ssrc|.
252 void AddRemoteVideoTrack(MediaStreamInterface* stream, 254 void AddRemoteVideoTrack(MediaStreamInterface* stream,
253 VideoTrackInterface* video_track, 255 VideoTrackInterface* video_track,
254 uint32 ssrc); 256 uint32_t ssrc);
255 // Remove the TrackHandler for |track|. 257 // Remove the TrackHandler for |track|.
256 void RemoveRemoteTrack(MediaStreamInterface* stream, 258 void RemoveRemoteTrack(MediaStreamInterface* stream,
257 MediaStreamTrackInterface* track); 259 MediaStreamTrackInterface* track);
258 260
259 // Remove all TrackHandlers for tracks in |stream| and make sure 261 // Remove all TrackHandlers for tracks in |stream| and make sure
260 // the audio_provider and video_provider is notified that the tracks has been 262 // the audio_provider and video_provider is notified that the tracks has been
261 // removed. 263 // removed.
262 void RemoveLocalStream(MediaStreamInterface* stream); 264 void RemoveLocalStream(MediaStreamInterface* stream);
263 265
264 // Create a LocalAudioTrackHandler and associate |audio_track| with |ssrc|. 266 // Create a LocalAudioTrackHandler and associate |audio_track| with |ssrc|.
265 void AddLocalAudioTrack(MediaStreamInterface* stream, 267 void AddLocalAudioTrack(MediaStreamInterface* stream,
266 AudioTrackInterface* audio_track, 268 AudioTrackInterface* audio_track,
267 uint32 ssrc); 269 uint32_t ssrc);
268 // Create a LocalVideoTrackHandler and associate |video_track| with |ssrc|. 270 // Create a LocalVideoTrackHandler and associate |video_track| with |ssrc|.
269 void AddLocalVideoTrack(MediaStreamInterface* stream, 271 void AddLocalVideoTrack(MediaStreamInterface* stream,
270 VideoTrackInterface* video_track, 272 VideoTrackInterface* video_track,
271 uint32 ssrc); 273 uint32_t ssrc);
272 // Remove the TrackHandler for |track|. 274 // Remove the TrackHandler for |track|.
273 void RemoveLocalTrack(MediaStreamInterface* stream, 275 void RemoveLocalTrack(MediaStreamInterface* stream,
274 MediaStreamTrackInterface* track); 276 MediaStreamTrackInterface* track);
275 277
276 private: 278 private:
277 typedef std::list<MediaStreamHandler*> StreamHandlerList; 279 typedef std::list<MediaStreamHandler*> StreamHandlerList;
278 MediaStreamHandler* FindStreamHandler(const StreamHandlerList& handlers, 280 MediaStreamHandler* FindStreamHandler(const StreamHandlerList& handlers,
279 MediaStreamInterface* stream); 281 MediaStreamInterface* stream);
280 MediaStreamHandler* CreateRemoteStreamHandler(MediaStreamInterface* stream); 282 MediaStreamHandler* CreateRemoteStreamHandler(MediaStreamInterface* stream);
281 MediaStreamHandler* CreateLocalStreamHandler(MediaStreamInterface* stream); 283 MediaStreamHandler* CreateLocalStreamHandler(MediaStreamInterface* stream);
282 void DeleteStreamHandler(StreamHandlerList* streamhandlers, 284 void DeleteStreamHandler(StreamHandlerList* streamhandlers,
283 MediaStreamInterface* stream); 285 MediaStreamInterface* stream);
284 286
285 StreamHandlerList local_streams_handlers_; 287 StreamHandlerList local_streams_handlers_;
286 StreamHandlerList remote_streams_handlers_; 288 StreamHandlerList remote_streams_handlers_;
287 AudioProviderInterface* audio_provider_; 289 AudioProviderInterface* audio_provider_;
288 VideoProviderInterface* video_provider_; 290 VideoProviderInterface* video_provider_;
289 }; 291 };
290 292
291 } // namespace webrtc 293 } // namespace webrtc
292 294
293 #endif // TALK_APP_WEBRTC_MEDIASTREAMHANDLER_H_ 295 #endif // TALK_APP_WEBRTC_MEDIASTREAMHANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698