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

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

Issue 1886123002: [experimental] MR: add support for H264 recording (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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. The 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. It has an internal Encoder with
25 // with its own threading subtleties, see the implementation file. This mirrors 25 // its own threading subtleties, see the implementation file. This mirrors the
26 // the other MediaStreamVideo* classes that are constructed/configured on Main 26 // other MediaStreamVideo* classes that are constructed/configured on Main
27 // Render thread but that pass frames on Render IO thread. 27 // Render thread but that pass frames on Render IO thread.
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 {
32 VP8,
33 VP9,
34 H264,
35 MAX = H264
36 };
37 class Encoder;
38
31 using OnEncodedVideoCB = 39 using OnEncodedVideoCB =
32 base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame, 40 base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame,
33 std::unique_ptr<std::string> encoded_data, 41 std::unique_ptr<std::string> encoded_data,
34 base::TimeTicks capture_timestamp, 42 base::TimeTicks capture_timestamp,
35 bool is_key_frame)>; 43 bool is_key_frame)>;
36 44
37 // |use_vp9| forces using VP9, otherwise VP8 will be used by default. 45 VideoTrackRecorder(CodecId codec,
38 VideoTrackRecorder(bool use_vp9,
39 const blink::WebMediaStreamTrack& track, 46 const blink::WebMediaStreamTrack& track,
40 const OnEncodedVideoCB& on_encoded_video_cb, 47 const OnEncodedVideoCB& on_encoded_video_cb,
41 int32_t bits_per_second); 48 int32_t bits_per_second);
42 ~VideoTrackRecorder() override; 49 ~VideoTrackRecorder() override;
43 50
44 void Pause(); 51 void Pause();
45 void Resume(); 52 void Resume();
46 53
47 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, 54 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame,
48 base::TimeTicks capture_time); 55 base::TimeTicks capture_time);
49 private: 56 private:
50 friend class VideoTrackRecorderTest; 57 friend class VideoTrackRecorderTest;
51 58
52 // Used to check that we are destroyed on the same thread we were created. 59 // Used to check that we are destroyed on the same thread we were created.
53 base::ThreadChecker main_render_thread_checker_; 60 base::ThreadChecker main_render_thread_checker_;
54 61
55 // We need to hold on to the Blink track to remove ourselves on dtor. 62 // We need to hold on to the Blink track to remove ourselves on dtor.
56 blink::WebMediaStreamTrack track_; 63 blink::WebMediaStreamTrack track_;
57 64
58 // Forward declaration and member of an inner class to encode using VPx. 65 // Forward declaration and member of an inner class to encode.
59 class VpxEncoder; 66 scoped_refptr<Encoder> encoder_;
60 const scoped_refptr<VpxEncoder> encoder_;
61 67
62 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); 68 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder);
63 }; 69 };
64 70
65 } // namespace content 71 } // namespace content
66 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ 72 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_
OLDNEW
« no previous file with comments | « content/renderer/media/media_recorder_handler_unittest.cc ('k') | content/renderer/media/video_track_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698