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

Unified Diff: content/renderer/media/video_track_recorder.h

Issue 1233033002: MediaStream: Adding VideoTrackRecorder class and unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: miu@s comments (except param piggybacking and threading stuff) 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: content/renderer/media/video_track_recorder.h
diff --git a/content/renderer/media/video_track_recorder.h b/content/renderer/media/video_track_recorder.h
new file mode 100644
index 0000000000000000000000000000000000000000..f47639bf7b76a16ce138b85457e8e1eec1ec1e38
--- /dev/null
+++ b/content/renderer/media/video_track_recorder.h
@@ -0,0 +1,62 @@
+// 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 CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_
+#define CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_
+
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/strings/string_piece.h"
+#include "base/threading/thread_checker.h"
+#include "content/public/renderer/media_stream_video_sink.h"
+#include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
+#include "ui/gfx/geometry/size.h"
+
+namespace content {
+
+// VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames
+// received from a Stream Video Track. The class is constructed and used on a
+// single thread, namely the main Render thread. It has an internal VpxEncoder
+// living on Render IO thread and using an encoding thread.
+class CONTENT_EXPORT VideoTrackRecorder
+ : NON_EXPORTED_BASE(public MediaStreamVideoSink) {
+ public:
+ using OnFirstFrameCB = base::Callback<uint64_t(const gfx::Size& frame_size,
+ double frame_rate)>;
+
+ using OnEncodedVideoCB = base::Callback<void(uint64_t track_number,
+ const base::StringPiece& data,
+ base::TimeDelta timestamp,
+ bool keyframe)>;
+
+ VideoTrackRecorder(
+ const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
+ const blink::WebMediaStreamTrack& track,
+ const OnFirstFrameCB& on_first_frame_cb,
+ const OnEncodedVideoCB& on_encoded_video_cb);
+ ~VideoTrackRecorder() override;
+
+ private:
+ friend class VideoTrackRecorderTest;
+
+ // Used to ping |encoder_->StartFrameEncode()| for testing.
+ void StartFrameEncodeForTesting(
+ const scoped_refptr<media::VideoFrame>& frame,
+ const base::TimeTicks& estimated_capture_time);
+
+ // Used to check that we are destroyed on the same thread we were created.
+ base::ThreadChecker main_render_thread_checker_;
+
+ // We need to hold on to the Blink track to remove ourselves on dtor.
+ const blink::WebMediaStreamTrack track_;
+
+ // Forward declaration and member of an inner class to encode using VPx.
+ class VpxEncoder;
+ const scoped_refptr<VpxEncoder> encoder_;
+
+ DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder);
+};
+
+} // namespace content
+#endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_

Powered by Google App Engine
This is Rietveld 408576698