| 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" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames | 31 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames |
| 32 // received from a Stream Video Track. This class is constructed and used on a | 32 // received from a Stream Video Track. This class is constructed and used on a |
| 33 // single thread, namely the main Render thread. This mirrors the other | 33 // single thread, namely the main Render thread. This mirrors the other |
| 34 // MediaStreamVideo* classes that are constructed/configured on Main Render | 34 // MediaStreamVideo* classes that are constructed/configured on Main Render |
| 35 // thread but that pass frames on Render IO thread. It has an internal Encoder | 35 // thread but that pass frames on Render IO thread. It has an internal Encoder |
| 36 // with its own threading subtleties, see the implementation file. | 36 // with its own threading subtleties, see the implementation file. |
| 37 class CONTENT_EXPORT VideoTrackRecorder | 37 class CONTENT_EXPORT VideoTrackRecorder |
| 38 : NON_EXPORTED_BASE(public MediaStreamVideoSink) { | 38 : NON_EXPORTED_BASE(public MediaStreamVideoSink) { |
| 39 public: | 39 public: |
| 40 // Do not change the order of codecs; add new ones right before LAST. | |
| 41 enum class CodecId { | 40 enum class CodecId { |
| 42 VP8, | 41 VP8, |
| 43 VP9, | 42 VP9, |
| 44 H264, | 43 H264, |
| 45 LAST | |
| 46 }; | 44 }; |
| 47 class Encoder; | 45 class Encoder; |
| 48 | 46 |
| 49 using OnEncodedVideoCB = | 47 using OnEncodedVideoCB = |
| 50 base::Callback<void(const media::WebmMuxer::VideoParameters& params, | 48 base::Callback<void(const media::WebmMuxer::VideoParameters& params, |
| 51 std::unique_ptr<std::string> encoded_data, | 49 std::unique_ptr<std::string> encoded_data, |
| 52 base::TimeTicks capture_timestamp, | 50 base::TimeTicks capture_timestamp, |
| 53 bool is_key_frame)>; | 51 bool is_key_frame)>; |
| 54 | 52 |
| 55 static CodecId GetPreferredCodecId(); | |
| 56 | |
| 57 VideoTrackRecorder(CodecId codec, | 53 VideoTrackRecorder(CodecId codec, |
| 58 const blink::WebMediaStreamTrack& track, | 54 const blink::WebMediaStreamTrack& track, |
| 59 const OnEncodedVideoCB& on_encoded_video_cb, | 55 const OnEncodedVideoCB& on_encoded_video_cb, |
| 60 int32_t bits_per_second); | 56 int32_t bits_per_second); |
| 61 ~VideoTrackRecorder() override; | 57 ~VideoTrackRecorder() override; |
| 62 | 58 |
| 63 void Pause(); | 59 void Pause(); |
| 64 void Resume(); | 60 void Resume(); |
| 65 | 61 |
| 66 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, | 62 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 90 // Used to track the paused state during the initialization process. | 86 // Used to track the paused state during the initialization process. |
| 91 bool paused_before_init_; | 87 bool paused_before_init_; |
| 92 | 88 |
| 93 base::WeakPtrFactory<VideoTrackRecorder> weak_ptr_factory_; | 89 base::WeakPtrFactory<VideoTrackRecorder> weak_ptr_factory_; |
| 94 | 90 |
| 95 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); | 91 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); |
| 96 }; | 92 }; |
| 97 | 93 |
| 98 } // namespace content | 94 } // namespace content |
| 99 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ | 95 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ |
| OLD | NEW |