Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_FILTERS_LIBWEBM_MUXER_H_ | |
| 6 #define MEDIA_FILTERS_LIBWEBM_MUXER_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/gtest_prod_util.h" | |
| 12 #include "base/numerics/safe_math.h" | |
| 13 #include "base/threading/thread_checker.h" | |
| 14 #include "base/time/time.h" | |
| 15 #include "media/base/media_export.h" | |
| 16 #include "third_party/libwebm/source/mkvmuxer.hpp" | |
| 17 #include "ui/gfx/geometry/size.h" | |
| 18 | |
| 19 namespace media { | |
| 20 | |
| 21 class MEDIA_EXPORT WebmMuxer : public mkvmuxer::IMkvWriter { | |
| 22 public: | |
| 23 typedef base::Callback<void(const char*, int)> WriteDataCB; | |
|
miu
2015/07/16 01:46:26
Please document when and how this callback will be
mcasas
2015/07/17 17:45:07
Done. Clarified a bit the WebM restrictions in the
| |
| 24 | |
| 25 explicit WebmMuxer(const WriteDataCB& write_data_callback); | |
| 26 ~WebmMuxer() override; | |
| 27 | |
| 28 void OnEncodedVideo(int track_index, | |
|
miu
2015/07/16 01:46:25
This method needs documentation. Below, for AddVi
mcasas
2015/07/17 17:45:07
Done.
| |
| 29 const std::string& encoded_data, | |
| 30 const base::TimeTicks& timestamp, | |
|
miu
2015/07/16 01:46:26
The caller should provide the media timestamp as a
mcasas
2015/07/17 17:45:07
Done. I like it.
| |
| 31 bool keyframe, | |
| 32 const gfx::Size& frame_size, | |
|
miu
2015/07/16 01:46:26
What happens when |frame_size| and/or |frame_rate|
mcasas
2015/07/17 17:45:07
As per offline discussion, what happens is that:
a
| |
| 33 double frame_rate); | |
| 34 | |
| 35 private: | |
| 36 friend class WebmMuxerTest; | |
| 37 FRIEND_TEST_ALL_PREFIXES(WebmMuxerTest, Write); | |
| 38 FRIEND_TEST_ALL_PREFIXES(WebmMuxerTest, OnEncodedVideo); | |
| 39 | |
| 40 // Creates and adds a new video track when receiving the first frame. | |
| 41 bool AddVideoTrack(const gfx::Size& frame_size, | |
| 42 double frame_rate, | |
| 43 int track_index_starting_from_one); | |
| 44 | |
| 45 // IMkvWriter interface. | |
| 46 mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override; | |
| 47 mkvmuxer::int64 Position() const override; | |
| 48 mkvmuxer::int32 Position(mkvmuxer::int64 position) override; | |
| 49 bool Seekable() const override; | |
| 50 void ElementStartNotify(mkvmuxer::uint64 element_id, | |
| 51 mkvmuxer::int64 position) override; | |
| 52 | |
| 53 // Used to DCHECK that we are called on the correct thread. | |
| 54 base::ThreadChecker thread_checker_; | |
| 55 | |
| 56 // Callback to dump written data as being called by libwebm. | |
| 57 const WriteDataCB write_data_callback_; | |
| 58 | |
| 59 // Class creation time. | |
| 60 const base::TimeTicks time_start_; | |
| 61 | |
| 62 // Rolling counter of the position in bytes of the written goo. | |
| 63 base::CheckedNumeric<uint64_t> position_; | |
| 64 | |
| 65 // Local cache of track indexes to speed up adding a new track when seen for | |
| 66 // the first time. | |
| 67 std::set<int> track_indexes_; | |
|
miu
2015/07/16 01:46:26
You don't need this since the same information can
mcasas
2015/07/17 17:45:07
Done.
| |
| 68 | |
| 69 // Owned pointer to the MkvMuxer active element. | |
| 70 scoped_ptr<mkvmuxer::Segment> segment_; | |
| 71 | |
| 72 DISALLOW_COPY_AND_ASSIGN(WebmMuxer); | |
| 73 }; | |
| 74 | |
| 75 } // namespace media | |
| 76 | |
| 77 #endif // MEDIA_FILTERS_LIBWEBM_MUXER_H_ | |
| OLD | NEW |