Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 WebmMuxer(bool use_vp9, const WriteDataCB& write_data_callback); |
|
miu
2015/10/07 18:16:35
Please add a comment that VP8 will be used if |use
mcasas
2015/10/07 21:01:15
Done.
miu
2015/10/07 21:56:56
Yeah, that's a good point. I suppose I'm fine wit
| |
| 44 ~WebmMuxer() override; | 44 ~WebmMuxer() override; |
| 45 | 45 |
| 46 // Adds a |video_frame| with |encoded_data.data()| to WebM Segment. | 46 // Adds a |video_frame| with |encoded_data.data()| to WebM Segment. |
| 47 void OnEncodedVideo(const scoped_refptr<VideoFrame>& video_frame, | 47 void OnEncodedVideo(const scoped_refptr<VideoFrame>& video_frame, |
| 48 scoped_ptr<std::string> encoded_data, | 48 scoped_ptr<std::string> encoded_data, |
| 49 base::TimeTicks timestamp, | 49 base::TimeTicks timestamp, |
| 50 bool is_key_frame); | 50 bool is_key_frame); |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 friend class WebmMuxerTest; | 53 friend class WebmMuxerTest; |
| 54 | 54 |
| 55 // Creates and adds a new video track. Called upon receiving the first | 55 // 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 | 56 // 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 | 57 // info, although individual frames passed to OnEncodedVideo() can have any |
| 58 // frame size. | 58 // frame size. |
| 59 void AddVideoTrack(const gfx::Size& frame_size, double frame_rate); | 59 void AddVideoTrack(const gfx::Size& frame_size, double frame_rate); |
| 60 | 60 |
| 61 // IMkvWriter interface. | 61 // IMkvWriter interface. |
| 62 mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override; | 62 mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override; |
| 63 mkvmuxer::int64 Position() const override; | 63 mkvmuxer::int64 Position() const override; |
| 64 mkvmuxer::int32 Position(mkvmuxer::int64 position) override; | 64 mkvmuxer::int32 Position(mkvmuxer::int64 position) override; |
| 65 bool Seekable() const override; | 65 bool Seekable() const override; |
| 66 void ElementStartNotify(mkvmuxer::uint64 element_id, | 66 void ElementStartNotify(mkvmuxer::uint64 element_id, |
| 67 mkvmuxer::int64 position) override; | 67 mkvmuxer::int64 position) override; |
| 68 | 68 |
| 69 // Used to DCHECK that we are called on the correct thread. | 69 // Used to DCHECK that we are called on the correct thread. |
| 70 base::ThreadChecker thread_checker_; | 70 base::ThreadChecker thread_checker_; |
| 71 | 71 |
| 72 const bool use_vp9_; | |
|
miu
2015/10/07 18:16:35
ditto: comment that meaning of "false" means VP8
mcasas
2015/10/07 21:01:14
Done.
| |
| 73 | |
| 72 // A caller-side identifier to interact with |segment_|, initialised upon | 74 // A caller-side identifier to interact with |segment_|, initialised upon |
| 73 // first frame arrival by AddVideoTrack(). | 75 // first frame arrival by AddVideoTrack(). |
| 74 uint64_t track_index_; | 76 uint64_t track_index_; |
| 75 | 77 |
| 76 // Origin of times for frame timestamps. | 78 // Origin of times for frame timestamps. |
| 77 base::TimeTicks first_frame_timestamp_; | 79 base::TimeTicks first_frame_timestamp_; |
| 78 | 80 |
| 79 // Callback to dump written data as being called by libwebm. | 81 // Callback to dump written data as being called by libwebm. |
| 80 const WriteDataCB write_data_callback_; | 82 const WriteDataCB write_data_callback_; |
| 81 | 83 |
| 82 // Rolling counter of the position in bytes of the written goo. | 84 // Rolling counter of the position in bytes of the written goo. |
| 83 base::CheckedNumeric<mkvmuxer::int64> position_; | 85 base::CheckedNumeric<mkvmuxer::int64> position_; |
| 84 | 86 |
| 85 // The MkvMuxer active element. | 87 // The MkvMuxer active element. |
| 86 mkvmuxer::Segment segment_; | 88 mkvmuxer::Segment segment_; |
| 87 | 89 |
| 88 DISALLOW_COPY_AND_ASSIGN(WebmMuxer); | 90 DISALLOW_COPY_AND_ASSIGN(WebmMuxer); |
| 89 }; | 91 }; |
| 90 | 92 |
| 91 } // namespace media | 93 } // namespace media |
| 92 | 94 |
| 93 #endif // MEDIA_FILTERS_LIBWEBM_MUXER_H_ | 95 #endif // MEDIA_FILTERS_LIBWEBM_MUXER_H_ |
| OLD | NEW |