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

Side by Side Diff: content/renderer/media/video_track_recorder.h

Issue 1893493003: VideoTrackRecorder: extract base class Encoder out of VpxEncoder (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 8 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_
6 #define CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ 6 #define CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/threading/thread_checker.h" 12 #include "base/threading/thread_checker.h"
13 #include "content/public/renderer/media_stream_video_sink.h" 13 #include "content/public/renderer/media_stream_video_sink.h"
14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
15 15
16 namespace media { 16 namespace media {
17 class VideoFrame; 17 class VideoFrame;
18 } // namespace media 18 } // namespace media
19 19
20 namespace content { 20 namespace content {
21 21
22 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames 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 23 // received from a Stream Video Track. This class is constructed and used on a
24 // single thread, namely the main Render thread. It has an internal VpxEncoder 24 // single thread, namely the main Render thread. This mirrors the other
25 // with its own threading subtleties, see the implementation file. This mirrors 25 // MediaStreamVideo* classes that are constructed/configured on Main Render
26 // the other MediaStreamVideo* classes that are constructed/configured on Main 26 // thread but that pass frames on Render IO thread. It has an internal Encoder
27 // Render thread but that pass frames on Render IO thread. 27 // with its own threading subtleties, see the implementation file.
28 class CONTENT_EXPORT VideoTrackRecorder 28 class CONTENT_EXPORT VideoTrackRecorder
29 : NON_EXPORTED_BASE(public MediaStreamVideoSink) { 29 : NON_EXPORTED_BASE(public MediaStreamVideoSink) {
30 public: 30 public:
31 enum class CodecId { 31 enum class CodecId {
32 VP8, 32 VP8,
33 VP9, 33 VP9,
34 }; 34 };
35 class Encoder;
35 36
36 using OnEncodedVideoCB = 37 using OnEncodedVideoCB =
37 base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame, 38 base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame,
38 std::unique_ptr<std::string> encoded_data, 39 std::unique_ptr<std::string> encoded_data,
39 base::TimeTicks capture_timestamp, 40 base::TimeTicks capture_timestamp,
40 bool is_key_frame)>; 41 bool is_key_frame)>;
41 42
42 VideoTrackRecorder(CodecId codec, 43 VideoTrackRecorder(CodecId codec,
43 const blink::WebMediaStreamTrack& track, 44 const blink::WebMediaStreamTrack& track,
44 const OnEncodedVideoCB& on_encoded_video_cb, 45 const OnEncodedVideoCB& on_encoded_video_cb,
45 int32_t bits_per_second); 46 int32_t bits_per_second);
46 ~VideoTrackRecorder() override; 47 ~VideoTrackRecorder() override;
47 48
48 void Pause(); 49 void Pause();
49 void Resume(); 50 void Resume();
50 51
51 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, 52 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame,
52 base::TimeTicks capture_time); 53 base::TimeTicks capture_time);
53 private: 54 private:
54 friend class VideoTrackRecorderTest; 55 friend class VideoTrackRecorderTest;
55 56
56 // Used to check that we are destroyed on the same thread we were created. 57 // Used to check that we are destroyed on the same thread we were created.
57 base::ThreadChecker main_render_thread_checker_; 58 base::ThreadChecker main_render_thread_checker_;
58 59
59 // We need to hold on to the Blink track to remove ourselves on dtor. 60 // We need to hold on to the Blink track to remove ourselves on dtor.
60 blink::WebMediaStreamTrack track_; 61 blink::WebMediaStreamTrack track_;
61 62
62 // Inner class to encode using whichever codec is configured. 63 // Inner class to encode using whichever codec is configured.
63 class VpxEncoder; 64 const scoped_refptr<Encoder> encoder_;
64 const scoped_refptr<VpxEncoder> encoder_;
65 65
66 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); 66 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder);
67 }; 67 };
68 68
69 } // namespace content 69 } // namespace content
70 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ 70 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_
OLDNEW
« no previous file with comments | « no previous file | content/renderer/media/video_track_recorder.cc » ('j') | content/renderer/media/video_track_recorder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698