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

Unified Diff: media/capture/webm_muxer.h

Issue 1233033002: MediaStream: Adding VideoTrackRecorder class and unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: miu@s comment on OnFirstFrameCB and OnEncodedVideoCB Created 5 years, 4 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
Index: media/capture/webm_muxer.h
diff --git a/media/capture/webm_muxer.h b/media/capture/webm_muxer.h
index eb93e005a5ad7170929b80f2ab034aaa60ee80ba..fc8f05b20204cae560948017a1b92aae2d043f0e 100644
--- a/media/capture/webm_muxer.h
+++ b/media/capture/webm_muxer.h
@@ -9,6 +9,7 @@
#include "base/callback.h"
#include "base/gtest_prod_util.h"
+#include "base/memory/weak_ptr.h"
#include "base/numerics/safe_math.h"
#include "base/strings/string_piece.h"
#include "base/threading/thread_checker.h"
@@ -23,8 +24,8 @@ namespace media {
// Matroska container [2], composed of an EBML header, and a single Segment
// including at least a Track Section and a number of SimpleBlocks each
// containing a single encoded video frame. WebM container has no Trailer.
-// Clients will push encoded VPx video frames one by one via OnEncodedVideo()
-// with indication of the Track they belong to, and libwebm will eventually ping
+// Clients will push encoded VPx video frames one by one via the
+// OnEncodedVideoCB() returned by AddVideoTrack(). libwebm will eventually ping
// the WriteDataCB passed on contructor with the wrapped encoded data. All
// operations must happen in a single thread, where WebmMuxer is created and
// destroyed.
@@ -41,14 +42,22 @@ class MEDIA_EXPORT WebmMuxer : public NON_EXPORTED_BASE(mkvmuxer::IMkvWriter) {
explicit WebmMuxer(const WriteDataCB& write_data_callback);
~WebmMuxer() override;
- // Creates and adds a new video track. Called before receiving the first
+ // Creates and adds a new video track. Called upon receiving the first
// frame of a given Track, adds |frame_size| and |frame_rate| to the Segment
// info, although individual frames passed to OnEncodedVideo() can have any
- // frame size. Returns the track_index to be used for OnEncodedVideo().
- uint64_t AddVideoTrack(const gfx::Size& frame_size, double frame_rate);
+ // frame size. Returns OnEncodedVideo() callback with a |track_number| bound
+ // in the callback.
+ using OnEncodedVideoCB = base::Callback<void(const base::StringPiece& data,
+ base::TimeDelta timestamp,
+ bool is_key_frame)>;
+ OnEncodedVideoCB AddVideoTrack(const gfx::Size& frame_size,
+ double frame_rate);
+
+ private:
+ friend class WebmMuxerTest;
// Adds a frame with |encoded_data.data()| to WebM Segment. |track_number| is
- // a caller-side identifier and must have been provided by AddVideoTrack().
+ // a caller-side identifier and must have been returned by AddVideoTrack().
// TODO(mcasas): Revisit how |encoded_data| is passed once the whole recording
// chain is setup (http://crbug.com/262211).
void OnEncodedVideo(uint64_t track_number,
@@ -56,9 +65,6 @@ class MEDIA_EXPORT WebmMuxer : public NON_EXPORTED_BASE(mkvmuxer::IMkvWriter) {
base::TimeDelta timestamp,
bool keyframe);
- private:
- friend class WebmMuxerTest;
-
// IMkvWriter interface.
mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override;
mkvmuxer::int64 Position() const override;
@@ -79,6 +85,8 @@ class MEDIA_EXPORT WebmMuxer : public NON_EXPORTED_BASE(mkvmuxer::IMkvWriter) {
// The MkvMuxer active element.
mkvmuxer::Segment segment_;
+ base::WeakPtrFactory<WebmMuxer> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(WebmMuxer);
};

Powered by Google App Engine
This is Rietveld 408576698