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

Side by Side Diff: talk/media/base/videocapturer.h

Issue 1655793003: Make cricket::VideoCapturer implement VideoSourceInterface (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed Android Created 4 years, 10 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 2010 Google Inc. 3 * Copyright 2010 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 20 matching lines...) Expand all
31 #define TALK_MEDIA_BASE_VIDEOCAPTURER_H_ 31 #define TALK_MEDIA_BASE_VIDEOCAPTURER_H_
32 32
33 #include <algorithm> 33 #include <algorithm>
34 #include <string> 34 #include <string>
35 #include <vector> 35 #include <vector>
36 36
37 #include "talk/media/base/mediachannel.h" 37 #include "talk/media/base/mediachannel.h"
38 #include "talk/media/base/videoadapter.h" 38 #include "talk/media/base/videoadapter.h"
39 #include "talk/media/base/videocommon.h" 39 #include "talk/media/base/videocommon.h"
40 #include "talk/media/base/videoframefactory.h" 40 #include "talk/media/base/videoframefactory.h"
41 #include "talk/media/base/videosourcebase.h"
41 #include "talk/media/devices/devicemanager.h" 42 #include "talk/media/devices/devicemanager.h"
42 #include "webrtc/base/basictypes.h" 43 #include "webrtc/base/basictypes.h"
43 #include "webrtc/base/criticalsection.h" 44 #include "webrtc/base/criticalsection.h"
45 #include "webrtc/media/base/videosourceinterface.h"
44 #include "webrtc/base/messagehandler.h" 46 #include "webrtc/base/messagehandler.h"
45 #include "webrtc/base/rollingaccumulator.h" 47 #include "webrtc/base/rollingaccumulator.h"
46 #include "webrtc/base/scoped_ptr.h" 48 #include "webrtc/base/scoped_ptr.h"
47 #include "webrtc/base/sigslot.h" 49 #include "webrtc/base/sigslot.h"
48 #include "webrtc/base/thread.h" 50 #include "webrtc/base/thread.h"
49 #include "webrtc/base/timing.h" 51 #include "webrtc/base/timing.h"
50 52
51 53
52 namespace cricket { 54 namespace cricket {
53 55
(...skipping 29 matching lines...) Expand all
83 // fourcc, pixel_width, and pixel_height should keep the same over frames. 85 // fourcc, pixel_width, and pixel_height should keep the same over frames.
84 int width; // in number of pixels 86 int width; // in number of pixels
85 int height; // in number of pixels 87 int height; // in number of pixels
86 uint32_t fourcc; // compression 88 uint32_t fourcc; // compression
87 uint32_t pixel_width; // width of a pixel, default is 1 89 uint32_t pixel_width; // width of a pixel, default is 1
88 uint32_t pixel_height; // height of a pixel, default is 1 90 uint32_t pixel_height; // height of a pixel, default is 1
89 int64_t time_stamp; // timestamp of when the frame was captured, in unix 91 int64_t time_stamp; // timestamp of when the frame was captured, in unix
90 // time with nanosecond units. 92 // time with nanosecond units.
91 uint32_t data_size; // number of bytes of the frame data 93 uint32_t data_size; // number of bytes of the frame data
92 94
93 webrtc::VideoRotation rotation; // rotation in degrees of the frame. 95 webrtc::VideoRotation rotation; // rotation in degrees of the frame.
94 96
95 void* data; // pointer to the frame data. This object allocates the 97 void* data; // pointer to the frame data. This object allocates the
96 // memory or points to an existing memory. 98 // memory or points to an existing memory.
97 99
98 private: 100 private:
99 RTC_DISALLOW_COPY_AND_ASSIGN(CapturedFrame); 101 RTC_DISALLOW_COPY_AND_ASSIGN(CapturedFrame);
100 }; 102 };
101 103
102 // VideoCapturer is an abstract class that defines the interfaces for video 104 // VideoCapturer is an abstract class that defines the interfaces for video
103 // capturing. The subclasses implement the video capturer for various types of 105 // capturing. The subclasses implement the video capturer for various types of
(...skipping 14 matching lines...) Expand all
118 // video_adapter()->OnOutputFormatRequest(desired_encoding_format) 120 // video_adapter()->OnOutputFormatRequest(desired_encoding_format)
119 // Start() 121 // Start()
120 // GetCaptureFormat() optionally 122 // GetCaptureFormat() optionally
121 // Stop() 123 // Stop()
122 // 124 //
123 // Assumption: 125 // Assumption:
124 // The Start() and Stop() methods are called by a single thread (E.g., the 126 // The Start() and Stop() methods are called by a single thread (E.g., the
125 // media engine thread). Hence, the VideoCapture subclasses dont need to be 127 // media engine thread). Hence, the VideoCapture subclasses dont need to be
126 // thread safe. 128 // thread safe.
127 // 129 //
128 class VideoCapturer 130 class VideoCapturer : public sigslot::has_slots<>,
129 : public sigslot::has_slots<>, 131 public rtc::MessageHandler,
130 public rtc::MessageHandler { 132 public rtc::VideoSourceBase {
pthatcher1 2016/02/03 15:38:35 Can we try making this "has a muxer" rather than "
131 public: 133 public:
132 // All signals are marshalled to |thread| or the creating thread if 134 // All signals are marshalled to |thread| or the creating thread if
133 // none is provided. 135 // none is provided.
134 VideoCapturer(); 136 VideoCapturer();
135 explicit VideoCapturer(rtc::Thread* thread); 137 explicit VideoCapturer(rtc::Thread* thread);
136 virtual ~VideoCapturer() {} 138 virtual ~VideoCapturer() {}
137 139
138 // Gets the id of the underlying device, which is available after the capturer 140 // Gets the id of the underlying device, which is available after the capturer
139 // is initialized. Can be used to determine if two capturers reference the 141 // is initialized. Can be used to determine if two capturers reference the
140 // same device. 142 // same device.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // When muting, produce black frames then pause the camera. 209 // When muting, produce black frames then pause the camera.
208 // When unmuting, start the camera. Camera starts unmuted. 210 // When unmuting, start the camera. Camera starts unmuted.
209 virtual bool MuteToBlackThenPause(bool muted); 211 virtual bool MuteToBlackThenPause(bool muted);
210 virtual bool IsMuted() const { 212 virtual bool IsMuted() const {
211 return muted_; 213 return muted_;
212 } 214 }
213 CaptureState capture_state() const { 215 CaptureState capture_state() const {
214 return capture_state_; 216 return capture_state_;
215 } 217 }
216 218
217 // Tells videocapturer whether to apply the pending rotation. By default, the 219 void OnSinkCapabilitiesChanged(
218 // rotation is applied and the generated frame is up right. When set to false, 220 const rtc::VideoSinkCapabilities& capabilities) override;
219 // generated frames will carry the rotation information from 221
220 // SetCaptureRotation. Return value indicates whether this operation succeeds.
221 virtual bool SetApplyRotation(bool enable);
222 virtual bool GetApplyRotation() { return apply_rotation_; } 222 virtual bool GetApplyRotation() { return apply_rotation_; }
223 223
224 // Returns true if the capturer is screencasting. This can be used to 224 // Returns true if the capturer is screencasting. This can be used to
225 // implement screencast specific behavior. 225 // implement screencast specific behavior.
226 virtual bool IsScreencast() const = 0; 226 virtual bool IsScreencast() const = 0;
227 227
228 // Caps the VideoCapturer's format according to max_format. It can e.g. be 228 // Caps the VideoCapturer's format according to max_format. It can e.g. be
229 // used to prevent cameras from capturing at a resolution or framerate that 229 // used to prevent cameras from capturing at a resolution or framerate that
230 // the capturer is capable of but not performing satisfactorily at. 230 // the capturer is capable of but not performing satisfactorily at.
231 // The capping is an upper bound for each component of the capturing format. 231 // The capping is an upper bound for each component of the capturing format.
(...skipping 18 matching lines...) Expand all
250 // Signal all capture state changes that are not a direct result of calling 250 // Signal all capture state changes that are not a direct result of calling
251 // Start(). 251 // Start().
252 sigslot::signal2<VideoCapturer*, CaptureState> SignalStateChange; 252 sigslot::signal2<VideoCapturer*, CaptureState> SignalStateChange;
253 // Frame callbacks are multithreaded to allow disconnect and connect to be 253 // Frame callbacks are multithreaded to allow disconnect and connect to be
254 // called concurrently. It also ensures that it is safe to call disconnect 254 // called concurrently. It also ensures that it is safe to call disconnect
255 // at any time which is needed since the signal may be called from an 255 // at any time which is needed since the signal may be called from an
256 // unmarshalled thread owned by the VideoCapturer. 256 // unmarshalled thread owned by the VideoCapturer.
257 // Signal the captured frame to downstream. 257 // Signal the captured frame to downstream.
258 sigslot::signal2<VideoCapturer*, const CapturedFrame*, 258 sigslot::signal2<VideoCapturer*, const CapturedFrame*,
259 sigslot::multi_threaded_local> SignalFrameCaptured; 259 sigslot::multi_threaded_local> SignalFrameCaptured;
260 // Signal the captured and possibly adapted frame to downstream consumers
261 // such as the encoder.
262 sigslot::signal2<VideoCapturer*, const VideoFrame*,
263 sigslot::multi_threaded_local> SignalVideoFrame;
264 260
265 // If true, run video adaptation. By default, video adaptation is enabled 261 // If true, run video adaptation. By default, video adaptation is enabled
266 // and users must call video_adapter()->OnOutputFormatRequest() 262 // and users must call video_adapter()->OnOutputFormatRequest()
267 // to receive frames. 263 // to receive frames.
268 bool enable_video_adapter() const { return enable_video_adapter_; } 264 bool enable_video_adapter() const { return enable_video_adapter_; }
269 void set_enable_video_adapter(bool enable_video_adapter) { 265 void set_enable_video_adapter(bool enable_video_adapter) {
270 enable_video_adapter_ = enable_video_adapter; 266 enable_video_adapter_ = enable_video_adapter;
271 } 267 }
272 268
273 CoordinatedVideoAdapter* video_adapter() { return &video_adapter_; } 269 CoordinatedVideoAdapter* video_adapter() { return &video_adapter_; }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 372
377 // Whether capturer should apply rotation to the frame before signaling it. 373 // Whether capturer should apply rotation to the frame before signaling it.
378 bool apply_rotation_; 374 bool apply_rotation_;
379 375
380 RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer); 376 RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer);
381 }; 377 };
382 378
383 } // namespace cricket 379 } // namespace cricket
384 380
385 #endif // TALK_MEDIA_BASE_VIDEOCAPTURER_H_ 381 #endif // TALK_MEDIA_BASE_VIDEOCAPTURER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698