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

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: Moved |track_index| and timestamp mgmt from VideoTrackRecorder into WebmMuxer Created 5 years, 4 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 media {
17 class VideoFrame;
18 } // namespace media
19
20 namespace content {
21
22 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames
23 // received from a Stream Video Track. The class is constructed and used on a
24 // single thread, namely the main Render thread. It has an internal VpxEncoder
25 // that uses a worker thread for encoding.
26 class CONTENT_EXPORT VideoTrackRecorder
27 : NON_EXPORTED_BASE(public MediaStreamVideoSink) {
28 public:
29 using OnEncodedVideoCB =
30 base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame,
31 const base::StringPiece& encoded_data,
32 base::TimeTicks capture_timestamp,
33 bool is_key_frame)>;
34
35 VideoTrackRecorder(const blink::WebMediaStreamTrack& track,
36 const OnEncodedVideoCB& on_encoded_video_cb);
37 ~VideoTrackRecorder() override;
38
39 private:
40 friend class VideoTrackRecorderTest;
41
42 // Used to ping |encoder_->StartFrameEncode()| for testing.
43 void StartFrameEncodeForTesting(const scoped_refptr<media::VideoFrame>& frame,
44 const base::TimeTicks& capture_time);
45
46 // Used to check that we are destroyed on the same thread we were created.
47 base::ThreadChecker main_render_thread_checker_;
48
49 // We need to hold on to the Blink track to remove ourselves on dtor.
50 const blink::WebMediaStreamTrack track_;
51
52 // Forward declaration and member of an inner class to encode using VPx.
53 class VpxEncoder;
54 const scoped_refptr<VpxEncoder> encoder_;
55
56 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder);
57 };
58
59 } // namespace content
60 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698