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

Unified Diff: media/filters/webm_muxer.h

Issue 1225123006: media/capture: Adding WebmMuxer class and unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@m_crbug262211__MSRecorder__2__libwebm_reland_in_third_party
Patch Set: emircan@ nits, rebase (only media.gyp affected), removed bool from WriteCallbackCB signature Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: media/filters/webm_muxer.h
diff --git a/media/filters/webm_muxer.h b/media/filters/webm_muxer.h
new file mode 100644
index 0000000000000000000000000000000000000000..fbc3c1ddb00d67f6e61aca68865cedf132303468
--- /dev/null
+++ b/media/filters/webm_muxer.h
@@ -0,0 +1,77 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_FILTERS_LIBWEBM_MUXER_H_
+#define MEDIA_FILTERS_LIBWEBM_MUXER_H_
+
+#include <set>
+
+#include "base/callback.h"
+#include "base/gtest_prod_util.h"
+#include "base/numerics/safe_math.h"
+#include "base/threading/thread_checker.h"
+#include "base/time/time.h"
+#include "media/base/media_export.h"
+#include "third_party/libwebm/source/mkvmuxer.hpp"
+#include "ui/gfx/geometry/size.h"
+
+namespace media {
+
+class MEDIA_EXPORT WebmMuxer : public mkvmuxer::IMkvWriter {
+ public:
+ 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
+
+ explicit WebmMuxer(const WriteDataCB& write_data_callback);
+ ~WebmMuxer() override;
+
+ 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.
+ const std::string& encoded_data,
+ 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.
+ bool keyframe,
+ 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
+ double frame_rate);
+
+ private:
+ friend class WebmMuxerTest;
+ FRIEND_TEST_ALL_PREFIXES(WebmMuxerTest, Write);
+ FRIEND_TEST_ALL_PREFIXES(WebmMuxerTest, OnEncodedVideo);
+
+ // Creates and adds a new video track when receiving the first frame.
+ bool AddVideoTrack(const gfx::Size& frame_size,
+ double frame_rate,
+ int track_index_starting_from_one);
+
+ // IMkvWriter interface.
+ mkvmuxer::int32 Write(const void* buf, mkvmuxer::uint32 len) override;
+ mkvmuxer::int64 Position() const override;
+ mkvmuxer::int32 Position(mkvmuxer::int64 position) override;
+ bool Seekable() const override;
+ void ElementStartNotify(mkvmuxer::uint64 element_id,
+ mkvmuxer::int64 position) override;
+
+ // Used to DCHECK that we are called on the correct thread.
+ base::ThreadChecker thread_checker_;
+
+ // Callback to dump written data as being called by libwebm.
+ const WriteDataCB write_data_callback_;
+
+ // Class creation time.
+ const base::TimeTicks time_start_;
+
+ // Rolling counter of the position in bytes of the written goo.
+ base::CheckedNumeric<uint64_t> position_;
+
+ // Local cache of track indexes to speed up adding a new track when seen for
+ // the first time.
+ 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.
+
+ // Owned pointer to the MkvMuxer active element.
+ scoped_ptr<mkvmuxer::Segment> segment_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebmMuxer);
+};
+
+} // namespace media
+
+#endif // MEDIA_FILTERS_LIBWEBM_MUXER_H_
« no previous file with comments | « media/DEPS ('k') | media/filters/webm_muxer.cc » ('j') | media/filters/webm_muxer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698