OLD | NEW |
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/common/features.h" |
13 #include "content/public/renderer/media_stream_video_sink.h" | 14 #include "content/public/renderer/media_stream_video_sink.h" |
14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 15 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
15 | 16 |
16 namespace media { | 17 namespace media { |
17 class VideoFrame; | 18 class VideoFrame; |
18 } // namespace media | 19 } // namespace media |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 | 22 |
22 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames | 23 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames |
23 // received from a Stream Video Track. This class is constructed and used on a | 24 // received from a Stream Video Track. This class is constructed and used on a |
24 // single thread, namely the main Render thread. This mirrors the other | 25 // single thread, namely the main Render thread. This mirrors the other |
25 // MediaStreamVideo* classes that are constructed/configured on Main Render | 26 // MediaStreamVideo* classes that are constructed/configured on Main Render |
26 // thread but that pass frames on Render IO thread. It has an internal Encoder | 27 // thread but that pass frames on Render IO thread. It has an internal Encoder |
27 // with its own threading subtleties, see the implementation file. | 28 // with its own threading subtleties, see the implementation file. |
28 class CONTENT_EXPORT VideoTrackRecorder | 29 class CONTENT_EXPORT VideoTrackRecorder |
29 : NON_EXPORTED_BASE(public MediaStreamVideoSink) { | 30 : NON_EXPORTED_BASE(public MediaStreamVideoSink) { |
30 public: | 31 public: |
31 enum class CodecId { | 32 enum class CodecId { |
32 VP8, | 33 VP8, |
33 VP9, | 34 VP9, |
| 35 #if BUILDFLAG(RTC_USE_H264) |
| 36 H264, |
| 37 #endif |
34 }; | 38 }; |
35 class Encoder; | 39 class Encoder; |
36 | 40 |
37 using OnEncodedVideoCB = | 41 using OnEncodedVideoCB = |
38 base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame, | 42 base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame, |
39 std::unique_ptr<std::string> encoded_data, | 43 std::unique_ptr<std::string> encoded_data, |
40 base::TimeTicks capture_timestamp, | 44 base::TimeTicks capture_timestamp, |
41 bool is_key_frame)>; | 45 bool is_key_frame)>; |
42 | 46 |
43 VideoTrackRecorder(CodecId codec, | 47 VideoTrackRecorder(CodecId codec, |
(...skipping 10 matching lines...) Expand all Loading... |
54 private: | 58 private: |
55 friend class VideoTrackRecorderTest; | 59 friend class VideoTrackRecorderTest; |
56 | 60 |
57 // Used to check that we are destroyed on the same thread we were created. | 61 // Used to check that we are destroyed on the same thread we were created. |
58 base::ThreadChecker main_render_thread_checker_; | 62 base::ThreadChecker main_render_thread_checker_; |
59 | 63 |
60 // We need to hold on to the Blink track to remove ourselves on dtor. | 64 // We need to hold on to the Blink track to remove ourselves on dtor. |
61 blink::WebMediaStreamTrack track_; | 65 blink::WebMediaStreamTrack track_; |
62 | 66 |
63 // Inner class to encode using whichever codec is configured. | 67 // Inner class to encode using whichever codec is configured. |
64 const scoped_refptr<Encoder> encoder_; | 68 scoped_refptr<Encoder> encoder_; |
65 | 69 |
66 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); | 70 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); |
67 }; | 71 }; |
68 | 72 |
69 } // namespace content | 73 } // namespace content |
70 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ | 74 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ |
OLD | NEW |