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

Side by Side Diff: media/capture/webm_muxer.h

Issue 1384483005: MediaStream Recorder: Support VP9 encoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: miu@s comments Created 5 years, 2 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_FILTERS_LIBWEBM_MUXER_H_ 5 #ifndef MEDIA_FILTERS_LIBWEBM_MUXER_H_
6 #define MEDIA_FILTERS_LIBWEBM_MUXER_H_ 6 #define MEDIA_FILTERS_LIBWEBM_MUXER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 22 matching lines...) Expand all
33 // WebmMuxer is designed for single thread use throughout. 33 // WebmMuxer is designed for single thread use throughout.
34 // [1] http://www.webmproject.org/docs/container/ 34 // [1] http://www.webmproject.org/docs/container/
35 // [2] http://www.matroska.org/technical/specs/index.html 35 // [2] http://www.matroska.org/technical/specs/index.html
36 // TODO(mcasas): Add support for Audio muxing. 36 // TODO(mcasas): Add support for Audio muxing.
37 class MEDIA_EXPORT WebmMuxer : public NON_EXPORTED_BASE(mkvmuxer::IMkvWriter) { 37 class MEDIA_EXPORT WebmMuxer : public NON_EXPORTED_BASE(mkvmuxer::IMkvWriter) {
38 public: 38 public:
39 // Callback to be called when WebmMuxer is ready to write a chunk of data, 39 // Callback to be called when WebmMuxer is ready to write a chunk of data,
40 // either any file header or a SingleBlock. 40 // either any file header or a SingleBlock.
41 using WriteDataCB = base::Callback<void(base::StringPiece)>; 41 using WriteDataCB = base::Callback<void(base::StringPiece)>;
42 42
43 explicit WebmMuxer(const WriteDataCB& write_data_callback); 43 // |use_vp9| forces using VP9, otherwise VP8 will be used by default.
44 WebmMuxer(bool use_vp9, const WriteDataCB& write_data_callback);
sandersd (OOO until July 31) 2015/10/08 00:11:04 I would vastly prefer an enum over a bool for this
mcasas 2015/10/08 18:08:46 Done.
44 ~WebmMuxer() override; 45 ~WebmMuxer() override;
45 46
46 // Adds a |video_frame| with |encoded_data.data()| to WebM Segment. 47 // Adds a |video_frame| with |encoded_data.data()| to WebM Segment.
47 void OnEncodedVideo(const scoped_refptr<VideoFrame>& video_frame, 48 void OnEncodedVideo(const scoped_refptr<VideoFrame>& video_frame,
48 scoped_ptr<std::string> encoded_data, 49 scoped_ptr<std::string> encoded_data,
49 base::TimeTicks timestamp, 50 base::TimeTicks timestamp,
50 bool is_key_frame); 51 bool is_key_frame);
51 52
52 private: 53 private:
53 friend class WebmMuxerTest; 54 friend class WebmMuxerTest;
54 55
55 // Creates and adds a new video track. Called upon receiving the first 56 // Creates and adds a new video track. Called upon receiving the first
56 // frame of a given Track, adds |frame_size| and |frame_rate| to the Segment 57 // frame of a given Track, adds |frame_size| and |frame_rate| to the Segment
57 // info, although individual frames passed to OnEncodedVideo() can have any 58 // info, although individual frames passed to OnEncodedVideo() can have any
58 // frame size. 59 // frame size.
59 void AddVideoTrack(const gfx::Size& frame_size, double frame_rate); 60 void AddVideoTrack(const gfx::Size& frame_size, double frame_rate);
60 61
61 // IMkvWriter interface. 62 // IMkvWriter interface.
62 mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override; 63 mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override;
63 mkvmuxer::int64 Position() const override; 64 mkvmuxer::int64 Position() const override;
64 mkvmuxer::int32 Position(mkvmuxer::int64 position) override; 65 mkvmuxer::int32 Position(mkvmuxer::int64 position) override;
65 bool Seekable() const override; 66 bool Seekable() const override;
66 void ElementStartNotify(mkvmuxer::uint64 element_id, 67 void ElementStartNotify(mkvmuxer::uint64 element_id,
67 mkvmuxer::int64 position) override; 68 mkvmuxer::int64 position) override;
68 69
69 // Used to DCHECK that we are called on the correct thread. 70 // Used to DCHECK that we are called on the correct thread.
70 base::ThreadChecker thread_checker_; 71 base::ThreadChecker thread_checker_;
71 72
73 // Force using VP9 for video encoding, otherwise VP8 will be used by default.
74 const bool use_vp9_;
75
72 // A caller-side identifier to interact with |segment_|, initialised upon 76 // A caller-side identifier to interact with |segment_|, initialised upon
73 // first frame arrival by AddVideoTrack(). 77 // first frame arrival by AddVideoTrack().
74 uint64_t track_index_; 78 uint64_t track_index_;
75 79
76 // Origin of times for frame timestamps. 80 // Origin of times for frame timestamps.
77 base::TimeTicks first_frame_timestamp_; 81 base::TimeTicks first_frame_timestamp_;
78 82
79 // Callback to dump written data as being called by libwebm. 83 // Callback to dump written data as being called by libwebm.
80 const WriteDataCB write_data_callback_; 84 const WriteDataCB write_data_callback_;
81 85
82 // Rolling counter of the position in bytes of the written goo. 86 // Rolling counter of the position in bytes of the written goo.
83 base::CheckedNumeric<mkvmuxer::int64> position_; 87 base::CheckedNumeric<mkvmuxer::int64> position_;
84 88
85 // The MkvMuxer active element. 89 // The MkvMuxer active element.
86 mkvmuxer::Segment segment_; 90 mkvmuxer::Segment segment_;
87 91
88 DISALLOW_COPY_AND_ASSIGN(WebmMuxer); 92 DISALLOW_COPY_AND_ASSIGN(WebmMuxer);
89 }; 93 };
90 94
91 } // namespace media 95 } // namespace media
92 96
93 #endif // MEDIA_FILTERS_LIBWEBM_MUXER_H_ 97 #endif // MEDIA_FILTERS_LIBWEBM_MUXER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698