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 28 matching lines...) Expand all Loading... | |
39 // either any file header or a SingleBlock. The chunk is described as a byte | 39 // either any file header or a SingleBlock. The chunk is described as a byte |
40 // array and a byte length. | 40 // array and a byte length. |
41 using WriteDataCB = base::Callback<void(const base::StringPiece&)>; | 41 using WriteDataCB = base::Callback<void(const base::StringPiece&)>; |
42 | 42 |
43 explicit WebmMuxer(const WriteDataCB& write_data_callback); | 43 explicit WebmMuxer(const WriteDataCB& write_data_callback); |
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 // TODO(mcasas): Revisit how |encoded_data| is passed once the whole recording | 47 // TODO(mcasas): Revisit how |encoded_data| is passed once the whole recording |
48 // chain is setup (http://crbug.com/262211). | 48 // chain is setup (http://crbug.com/262211). |
49 void OnEncodedVideo(const scoped_refptr<VideoFrame>& video_frame, | 49 void OnEncodedVideo(int track_index, |
50 const scoped_refptr<VideoFrame>& video_frame, | |
50 const base::StringPiece& encoded_data, | 51 const base::StringPiece& encoded_data, |
51 base::TimeTicks timestamp, | 52 base::TimeTicks timestamp, |
52 bool is_key_frame); | 53 bool is_key_frame); |
53 | 54 |
55 int GetNextTrackIndex(); | |
56 | |
54 private: | 57 private: |
55 friend class WebmMuxerTest; | 58 friend class WebmMuxerTest; |
59 struct MuxerArg { | |
ajose
2015/09/18 18:28:58
Change to VideoMuxerArg or similar? These tests wi
msu.koo
2015/09/21 04:28:37
Done.
| |
60 MuxerArg(const base::TimeTicks& first_frame_timestamp, uint64 track_number) | |
61 : first_frame_timestamp(first_frame_timestamp), | |
62 track_number(track_number) {} | |
63 | |
64 base::TimeTicks first_frame_timestamp; | |
65 uint64 track_number; | |
66 }; | |
56 | 67 |
57 // Creates and adds a new video track. Called upon receiving the first | 68 // Creates and adds a new video track. Called upon receiving the first |
58 // frame of a given Track, adds |frame_size| and |frame_rate| to the Segment | 69 // frame of a given Track, adds |frame_size| and |frame_rate| to the Segment |
59 // info, although individual frames passed to OnEncodedVideo() can have any | 70 // info, although individual frames passed to OnEncodedVideo() can have any |
60 // frame size. | 71 // frame size. |
61 void AddVideoTrack(const gfx::Size& frame_size, double frame_rate); | 72 uint64 AddVideoTrack(const gfx::Size& frame_size, double frame_rate); |
62 | 73 |
63 // IMkvWriter interface. | 74 // IMkvWriter interface. |
64 mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override; | 75 mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override; |
65 mkvmuxer::int64 Position() const override; | 76 mkvmuxer::int64 Position() const override; |
66 mkvmuxer::int32 Position(mkvmuxer::int64 position) override; | 77 mkvmuxer::int32 Position(mkvmuxer::int64 position) override; |
67 bool Seekable() const override; | 78 bool Seekable() const override; |
68 void ElementStartNotify(mkvmuxer::uint64 element_id, | 79 void ElementStartNotify(mkvmuxer::uint64 element_id, |
69 mkvmuxer::int64 position) override; | 80 mkvmuxer::int64 position) override; |
70 | 81 |
71 // Used to DCHECK that we are called on the correct thread (usually IO) | 82 // Used to DCHECK that we are called on the correct thread (usually IO) |
72 base::ThreadChecker thread_checker_; | 83 base::ThreadChecker thread_checker_; |
73 | 84 |
74 // A caller-side identifier to interact with |segment_|, initialised upon | 85 // Arguments for each tracks to mkvmuxer. |
75 // first frame arrival by AddVideoTrack(). | 86 std::vector<MuxerArg> muxer_args; |
ajose
2015/09/18 18:28:58
muxer_args_ (or muxer_args_for_video_ or something
msu.koo
2015/09/21 04:28:37
Done.
| |
76 uint64_t track_index_; | |
77 | |
78 // Origin of times for frame timestamps. | |
79 base::TimeTicks first_frame_timestamp_; | |
80 | 87 |
81 // Callback to dump written data as being called by libwebm. | 88 // Callback to dump written data as being called by libwebm. |
82 const WriteDataCB write_data_callback_; | 89 const WriteDataCB write_data_callback_; |
83 | 90 |
84 // Rolling counter of the position in bytes of the written goo. | 91 // Rolling counter of the position in bytes of the written goo. |
85 base::CheckedNumeric<mkvmuxer::int64> position_; | 92 base::CheckedNumeric<mkvmuxer::int64> position_; |
86 | 93 |
87 // The MkvMuxer active element. | 94 // The MkvMuxer active element. |
88 mkvmuxer::Segment segment_; | 95 mkvmuxer::Segment segment_; |
89 | 96 |
90 DISALLOW_COPY_AND_ASSIGN(WebmMuxer); | 97 DISALLOW_COPY_AND_ASSIGN(WebmMuxer); |
91 }; | 98 }; |
92 | 99 |
93 } // namespace media | 100 } // namespace media |
94 | 101 |
95 #endif // MEDIA_FILTERS_LIBWEBM_MUXER_H_ | 102 #endif // MEDIA_FILTERS_LIBWEBM_MUXER_H_ |
OLD | NEW |