| 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_MUXERS_WEBM_MUXER_H_ | 5 #ifndef MEDIA_MUXERS_WEBM_MUXER_H_ |
| 6 #define MEDIA_MUXERS_WEBM_MUXER_H_ | 6 #define MEDIA_MUXERS_WEBM_MUXER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <deque> | 10 #include <deque> |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // |codec| can be VP8 or VP9 and should coincide with whatever is sent in | 60 // |codec| can be VP8 or VP9 and should coincide with whatever is sent in |
| 61 // OnEncodedVideo(). | 61 // OnEncodedVideo(). |
| 62 WebmMuxer(VideoCodec codec, | 62 WebmMuxer(VideoCodec codec, |
| 63 bool has_video_, | 63 bool has_video_, |
| 64 bool has_audio_, | 64 bool has_audio_, |
| 65 const WriteDataCB& write_data_callback); | 65 const WriteDataCB& write_data_callback); |
| 66 ~WebmMuxer() override; | 66 ~WebmMuxer() override; |
| 67 | 67 |
| 68 // Functions to add video and audio frames with |encoded_data.data()| | 68 // Functions to add video and audio frames with |encoded_data.data()| |
| 69 // to WebM Segment. Either one returns true on success. | 69 // to WebM Segment. Either one returns true on success. |
| 70 // |encoded_alpha| represents the encode output of alpha channel when |
| 71 // available, can be nullptr otherwise. |
| 70 bool OnEncodedVideo(const VideoParameters& params, | 72 bool OnEncodedVideo(const VideoParameters& params, |
| 71 std::unique_ptr<std::string> encoded_data, | 73 std::unique_ptr<std::string> encoded_data, |
| 74 std::unique_ptr<std::string> encoded_alpha, |
| 72 base::TimeTicks timestamp, | 75 base::TimeTicks timestamp, |
| 73 bool is_key_frame); | 76 bool is_key_frame); |
| 74 bool OnEncodedAudio(const media::AudioParameters& params, | 77 bool OnEncodedAudio(const media::AudioParameters& params, |
| 75 std::unique_ptr<std::string> encoded_data, | 78 std::unique_ptr<std::string> encoded_data, |
| 76 base::TimeTicks timestamp); | 79 base::TimeTicks timestamp); |
| 77 | 80 |
| 78 void Pause(); | 81 void Pause(); |
| 79 void Resume(); | 82 void Resume(); |
| 80 | 83 |
| 81 void ForceOneLibWebmErrorForTesting() { force_one_libwebm_error_ = true; } | 84 void ForceOneLibWebmErrorForTesting() { force_one_libwebm_error_ = true; } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 94 // IMkvWriter interface. | 97 // IMkvWriter interface. |
| 95 mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override; | 98 mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override; |
| 96 mkvmuxer::int64 Position() const override; | 99 mkvmuxer::int64 Position() const override; |
| 97 mkvmuxer::int32 Position(mkvmuxer::int64 position) override; | 100 mkvmuxer::int32 Position(mkvmuxer::int64 position) override; |
| 98 bool Seekable() const override; | 101 bool Seekable() const override; |
| 99 void ElementStartNotify(mkvmuxer::uint64 element_id, | 102 void ElementStartNotify(mkvmuxer::uint64 element_id, |
| 100 mkvmuxer::int64 position) override; | 103 mkvmuxer::int64 position) override; |
| 101 | 104 |
| 102 // Helper to simplify saving frames. Returns true on success. | 105 // Helper to simplify saving frames. Returns true on success. |
| 103 bool AddFrame(std::unique_ptr<std::string> encoded_data, | 106 bool AddFrame(std::unique_ptr<std::string> encoded_data, |
| 107 std::unique_ptr<std::string> encoded_alpha_data, |
| 104 uint8_t track_index, | 108 uint8_t track_index, |
| 105 base::TimeDelta timestamp, | 109 base::TimeDelta timestamp, |
| 106 bool is_key_frame); | 110 bool is_key_frame); |
| 107 | 111 |
| 108 // Used to DCHECK that we are called on the correct thread. | 112 // Used to DCHECK that we are called on the correct thread. |
| 109 base::ThreadChecker thread_checker_; | 113 base::ThreadChecker thread_checker_; |
| 110 | 114 |
| 111 // Video Codec configured on construction. | 115 // Video Codec configured on construction. |
| 112 const VideoCodec video_codec_; | 116 const VideoCodec video_codec_; |
| 113 | 117 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 138 | 142 |
| 139 // The MkvMuxer active element. | 143 // The MkvMuxer active element. |
| 140 mkvmuxer::Segment segment_; | 144 mkvmuxer::Segment segment_; |
| 141 // Flag to force the next call to a |segment_| method to return false. | 145 // Flag to force the next call to a |segment_| method to return false. |
| 142 bool force_one_libwebm_error_; | 146 bool force_one_libwebm_error_; |
| 143 | 147 |
| 144 // Hold on to all encoded video frames to dump them with and when audio is | 148 // Hold on to all encoded video frames to dump them with and when audio is |
| 145 // received, if expected, since WebM headers can only be written once. | 149 // received, if expected, since WebM headers can only be written once. |
| 146 struct EncodedVideoFrame { | 150 struct EncodedVideoFrame { |
| 147 EncodedVideoFrame(std::unique_ptr<std::string> data, | 151 EncodedVideoFrame(std::unique_ptr<std::string> data, |
| 152 std::unique_ptr<std::string> alpha_data, |
| 148 base::TimeTicks timestamp, | 153 base::TimeTicks timestamp, |
| 149 bool is_keyframe); | 154 bool is_keyframe); |
| 150 ~EncodedVideoFrame(); | 155 ~EncodedVideoFrame(); |
| 151 | 156 |
| 152 std::unique_ptr<std::string> data; | 157 std::unique_ptr<std::string> data; |
| 158 std::unique_ptr<std::string> alpha_data; |
| 153 base::TimeTicks timestamp; | 159 base::TimeTicks timestamp; |
| 154 bool is_keyframe; | 160 bool is_keyframe; |
| 155 | 161 |
| 156 private: | 162 private: |
| 157 DISALLOW_IMPLICIT_CONSTRUCTORS(EncodedVideoFrame); | 163 DISALLOW_IMPLICIT_CONSTRUCTORS(EncodedVideoFrame); |
| 158 }; | 164 }; |
| 159 std::deque<std::unique_ptr<EncodedVideoFrame>> encoded_frames_queue_; | 165 std::deque<std::unique_ptr<EncodedVideoFrame>> encoded_frames_queue_; |
| 160 | 166 |
| 161 DISALLOW_COPY_AND_ASSIGN(WebmMuxer); | 167 DISALLOW_COPY_AND_ASSIGN(WebmMuxer); |
| 162 }; | 168 }; |
| 163 | 169 |
| 164 } // namespace media | 170 } // namespace media |
| 165 | 171 |
| 166 #endif // MEDIA_MUXERS_WEBM_MUXER_H_ | 172 #endif // MEDIA_MUXERS_WEBM_MUXER_H_ |
| OLD | NEW |