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

Side by Side 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: tomfinegan@ comments, added a capture thread 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 unified diff | Download patch
OLDNEW
(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 CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_
6 #define CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_
7
8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/strings/string_piece.h"
11 #include "base/threading/thread_checker.h"
12 #include "content/public/renderer/media_stream_video_sink.h"
13 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
14 #include "ui/gfx/geometry/size.h"
15
16 namespace content {
17
18 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames
19 // received from a Stream Video Track. The class is constructed and used on a
20 // single thread, namely the main Render thread. It has an internal VpxEncoder
21 // living on Render IO thread and using an encoding thread.
miu 2015/07/27 22:30:09 1. This should not be done on the IO thread. 2. I
mcasas 2015/07/31 11:26:27 What I meant is that callbacks to the "internal Vp
22 class CONTENT_EXPORT VideoTrackRecorder
23 : NON_EXPORTED_BASE(public MediaStreamVideoSink) {
24 public:
25 using OnFirstFrameCB = base::Callback<uint64_t(const gfx::Size& frame_size,
26 double frame_rate)>;
27
28 using OnEncodedVideoCB = base::Callback<void(uint64_t track_number,
miu 2015/07/27 22:30:09 |track_number| does not belong in this API nor thi
mcasas 2015/07/31 11:26:27 I'm not sure I understand. Do you mean OnFirstFram
miu 2015/08/04 04:06:30 Sorry. I wasn't very clear here. Basically, I th
mcasas 2015/08/11 09:35:17 I agree that the |track_index| should not be surfa
29 const base::StringPiece& data,
30 base::TimeDelta timestamp,
31 bool keyframe)>;
32
33 VideoTrackRecorder(
34 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
35 const blink::WebMediaStreamTrack& track,
36 const OnFirstFrameCB& on_first_frame_cb,
37 const OnEncodedVideoCB& on_encoded_video_cb);
38 ~VideoTrackRecorder() override;
39
40 private:
41 friend class VideoTrackRecorderTest;
42
43 // Used to ping |encoder_->EncodeOnIo()| for testing.
44 void EncodeOnIoForTesting(const scoped_refptr<media::VideoFrame>& frame,
45 const base::TimeTicks& estimated_capture_time);
46
47 // Used to check that we are destroyed on the same thread we were created.
48 base::ThreadChecker main_render_thread_checker_;
49
50 // We need to hold on to the Blink track to remove ourselves on dtor.
51 const blink::WebMediaStreamTrack track_;
52
53 // Forward declaration and member of an inner class to encode using VPx.
54 class VpxEncoder;
55 const scoped_refptr<VpxEncoder> encoder_;
56
57 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder);
58 };
59
60 } // namespace content
61 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698