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_RECORDER_VIDEO_TRACK_RECORDER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_RECORDER_VIDEO_TRACK_RECORDER_H_ |
6 #define CONTENT_RENDERER_MEDIA_RECORDER_VIDEO_TRACK_RECORDER_H_ | 6 #define CONTENT_RENDERER_MEDIA_RECORDER_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/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "content/public/common/features.h" | 15 #include "content/public/common/features.h" |
16 #include "content/public/renderer/media_stream_video_sink.h" | 16 #include "content/public/renderer/media_stream_video_sink.h" |
17 #include "media/muxers/webm_muxer.h" | 17 #include "media/muxers/webm_muxer.h" |
18 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 18 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
19 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
20 | 20 |
| 21 #if BUILDFLAG(RTC_USE_H264) || defined(OS_ANDROID) |
| 22 // H264 encoding is supported on Android using the platform encode |
| 23 // accelerator, and elsewhere using OpenH264. |
| 24 #define IS_H264_SUPPORTED |
| 25 #endif |
| 26 |
21 namespace base { | 27 namespace base { |
22 class Thread; | 28 class Thread; |
23 } // namespace base | 29 } // namespace base |
24 | 30 |
25 namespace cc { | 31 namespace cc { |
26 class PaintCanvas; | 32 class PaintCanvas; |
27 } // namespace cc | 33 } // namespace cc |
28 | 34 |
29 namespace media { | 35 namespace media { |
30 class SkCanvasVideoRenderer; | 36 class SkCanvasVideoRenderer; |
31 class VideoFrame; | 37 class VideoFrame; |
32 } // namespace media | 38 } // namespace media |
33 | 39 |
34 namespace video_track_recorder { | 40 namespace video_track_recorder { |
| 41 #if defined(OS_ANDROID) |
| 42 const int kVEAEncoderMinResolutionWidth = 176; |
| 43 const int kVEAEncoderMinResolutionHeight = 144; |
| 44 #else |
35 const int kVEAEncoderMinResolutionWidth = 640; | 45 const int kVEAEncoderMinResolutionWidth = 640; |
36 const int kVEAEncoderMinResolutionHeight = 480; | 46 const int kVEAEncoderMinResolutionHeight = 480; |
| 47 #endif |
37 } // namespace video_track_recorder | 48 } // namespace video_track_recorder |
38 | 49 |
39 namespace content { | 50 namespace content { |
40 | 51 |
41 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames | 52 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames |
42 // received from a Stream Video Track. This class is constructed and used on a | 53 // received from a Stream Video Track. This class is constructed and used on a |
43 // single thread, namely the main Render thread. This mirrors the other | 54 // single thread, namely the main Render thread. This mirrors the other |
44 // MediaStreamVideo* classes that are constructed/configured on Main Render | 55 // MediaStreamVideo* classes that are constructed/configured on Main Render |
45 // thread but that pass frames on Render IO thread. It has an internal Encoder | 56 // thread but that pass frames on Render IO thread. It has an internal Encoder |
46 // with its own threading subtleties, see the implementation file. | 57 // with its own threading subtleties, see the implementation file. |
47 class CONTENT_EXPORT VideoTrackRecorder | 58 class CONTENT_EXPORT VideoTrackRecorder |
48 : NON_EXPORTED_BASE(public MediaStreamVideoSink) { | 59 : NON_EXPORTED_BASE(public MediaStreamVideoSink) { |
49 public: | 60 public: |
50 // Do not change the order of codecs; add new ones right before LAST. | 61 // Do not change the order of codecs; add new ones right before LAST. |
51 enum class CodecId { | 62 enum class CodecId { |
52 VP8, | 63 VP8, |
53 VP9, | 64 VP9, |
54 #if BUILDFLAG(RTC_USE_H264) | 65 #if defined(IS_H264_SUPPORTED) |
55 H264, | 66 H264, |
56 #endif | 67 #endif |
57 LAST | 68 LAST |
58 }; | 69 }; |
59 | 70 |
60 using OnEncodedVideoCB = | 71 using OnEncodedVideoCB = |
61 base::Callback<void(const media::WebmMuxer::VideoParameters& params, | 72 base::Callback<void(const media::WebmMuxer::VideoParameters& params, |
62 std::unique_ptr<std::string> encoded_data, | 73 std::unique_ptr<std::string> encoded_data, |
63 std::unique_ptr<std::string> encoded_alpha, | 74 std::unique_ptr<std::string> encoded_alpha, |
64 base::TimeTicks capture_timestamp, | 75 base::TimeTicks capture_timestamp, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // Used to track the paused state during the initialization process. | 200 // Used to track the paused state during the initialization process. |
190 bool paused_before_init_; | 201 bool paused_before_init_; |
191 | 202 |
192 base::WeakPtrFactory<VideoTrackRecorder> weak_ptr_factory_; | 203 base::WeakPtrFactory<VideoTrackRecorder> weak_ptr_factory_; |
193 | 204 |
194 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); | 205 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); |
195 }; | 206 }; |
196 | 207 |
197 } // namespace content | 208 } // namespace content |
198 #endif // CONTENT_RENDERER_MEDIA_RECORDER_VIDEO_TRACK_RECORDER_H_ | 209 #endif // CONTENT_RENDERER_MEDIA_RECORDER_VIDEO_TRACK_RECORDER_H_ |
OLD | NEW |