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

Unified Diff: webrtc/media/base/videocapturer.h

Issue 2357113002: Revert of Delete VideoFrameFactory, CapturedFrame, and related code. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/media/base/videoadapter_unittest.cc ('k') | webrtc/media/base/videocapturer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/base/videocapturer.h
diff --git a/webrtc/media/base/videocapturer.h b/webrtc/media/base/videocapturer.h
index bb25d2a678fc05cb5b07fa9a449bdd166aabb6db..eb868d9877c0fc664b3f7fc0a042c154f74f90b6 100644
--- a/webrtc/media/base/videocapturer.h
+++ b/webrtc/media/base/videocapturer.h
@@ -28,6 +28,7 @@
#include "webrtc/media/base/videoadapter.h"
#include "webrtc/media/base/videobroadcaster.h"
#include "webrtc/media/base/videocommon.h"
+#include "webrtc/media/base/videoframefactory.h"
namespace cricket {
@@ -43,6 +44,38 @@
};
class VideoFrame;
+
+struct CapturedFrame {
+ static const uint32_t kFrameHeaderSize = 40; // Size from width to data_size.
+ static const uint32_t kUnknownDataSize = 0xFFFFFFFF;
+
+ CapturedFrame();
+
+ // Get the number of bytes of the frame data. If data_size is known, return
+ // it directly. Otherwise, calculate the size based on width, height, and
+ // fourcc. Return true if succeeded.
+ bool GetDataSize(uint32_t* size) const;
+
+ // The width and height of the captured frame could be different from those
+ // of VideoFormat. Once the first frame is captured, the width, height,
+ // fourcc, pixel_width, and pixel_height should keep the same over frames.
+ int width; // in number of pixels
+ int height; // in number of pixels
+ uint32_t fourcc; // compression
+ uint32_t pixel_width; // width of a pixel, default is 1
+ uint32_t pixel_height; // height of a pixel, default is 1
+ int64_t time_stamp; // timestamp of when the frame was captured, in unix
+ // time with nanosecond units.
+ uint32_t data_size; // number of bytes of the frame data
+
+ webrtc::VideoRotation rotation; // rotation in degrees of the frame.
+
+ void* data; // pointer to the frame data. This object allocates the
+ // memory or points to an existing memory.
+
+ private:
+ RTC_DISALLOW_COPY_AND_ASSIGN(CapturedFrame);
+};
// VideoCapturer is an abstract class that defines the interfaces for video
// capturing. The subclasses implement the video capturer for various types of
@@ -171,6 +204,13 @@
// Signal all capture state changes that are not a direct result of calling
// Start().
sigslot::signal2<VideoCapturer*, CaptureState> SignalStateChange;
+ // Frame callbacks are multithreaded to allow disconnect and connect to be
+ // called concurrently. It also ensures that it is safe to call disconnect
+ // at any time which is needed since the signal may be called from an
+ // unmarshalled thread owned by the VideoCapturer.
+ // Signal the captured frame to downstream.
+ sigslot::signal2<VideoCapturer*, const CapturedFrame*,
+ sigslot::multi_threaded_local> SignalFrameCaptured;
// If true, run video adaptation. By default, video adaptation is enabled
// and users must call video_adapter()->OnOutputFormatRequest()
@@ -179,6 +219,9 @@
void set_enable_video_adapter(bool enable_video_adapter) {
enable_video_adapter_ = enable_video_adapter;
}
+
+ // Takes ownership.
+ void set_frame_factory(VideoFrameFactory* frame_factory);
bool GetInputSize(int* width, int* height);
@@ -220,6 +263,10 @@
int* crop_y,
int64_t* translated_camera_time_us);
+ // Callback attached to SignalFrameCaptured where SignalVideoFrames is called.
+ void OnFrameCaptured(VideoCapturer* video_capturer,
+ const CapturedFrame* captured_frame);
+
// Called when a frame has been captured and converted to a
// VideoFrame. OnFrame can be called directly by an implementation
// that does not use SignalFrameCaptured or OnFrameCaptured. The
@@ -244,6 +291,7 @@
}
void SetSupportedFormats(const std::vector<VideoFormat>& formats);
+ VideoFrameFactory* frame_factory() { return frame_factory_.get(); }
private:
void Construct();
@@ -253,6 +301,9 @@
int64_t GetFormatDistance(const VideoFormat& desired,
const VideoFormat& supported);
+ // Convert captured frame to readable string for LOG messages.
+ std::string ToString(const CapturedFrame* frame) const;
+
// Updates filtered_supported_formats_ so that it contains the formats in
// supported_formats_ that fulfill all applied restrictions.
void UpdateFilteredSupportedFormats();
@@ -264,6 +315,7 @@
rtc::ThreadChecker thread_checker_;
std::string id_;
CaptureState capture_state_;
+ std::unique_ptr<VideoFrameFactory> frame_factory_;
std::unique_ptr<VideoFormat> capture_format_;
std::vector<VideoFormat> supported_formats_;
std::unique_ptr<VideoFormat> max_format_;
@@ -283,8 +335,7 @@
int input_width_ GUARDED_BY(frame_stats_crit_);
int input_height_ GUARDED_BY(frame_stats_crit_);
- // Whether capturer should apply rotation to the frame before
- // passing it on to the registered sinks.
+ // Whether capturer should apply rotation to the frame before signaling it.
bool apply_rotation_;
// State for the timestamp translation.
« no previous file with comments | « webrtc/media/base/videoadapter_unittest.cc ('k') | webrtc/media/base/videocapturer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698