Chromium Code Reviews| 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/memory/weak_ptr.h" | |
| 13 #include "base/single_thread_task_runner.h" | |
|
mcasas
2016/05/25 16:42:47
Forward declare SingleThreadTaskRunner
emircan
2016/05/27 04:27:20
Done.
| |
| 12 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 13 #include "content/public/common/features.h" | 15 #include "content/public/common/features.h" |
| 14 #include "content/public/renderer/media_stream_video_sink.h" | 16 #include "content/public/renderer/media_stream_video_sink.h" |
| 15 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 17 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 16 | 18 |
| 17 namespace media { | 19 namespace media { |
| 18 class VideoFrame; | 20 class VideoFrame; |
| 19 } // namespace media | 21 } // namespace media |
| 20 | 22 |
| 21 namespace content { | 23 namespace content { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 41 std::unique_ptr<std::string> encoded_data, | 43 std::unique_ptr<std::string> encoded_data, |
| 42 base::TimeTicks capture_timestamp, | 44 base::TimeTicks capture_timestamp, |
| 43 bool is_key_frame)>; | 45 bool is_key_frame)>; |
| 44 | 46 |
| 45 VideoTrackRecorder(CodecId codec, | 47 VideoTrackRecorder(CodecId codec, |
| 46 const blink::WebMediaStreamTrack& track, | 48 const blink::WebMediaStreamTrack& track, |
| 47 const OnEncodedVideoCB& on_encoded_video_cb, | 49 const OnEncodedVideoCB& on_encoded_video_cb, |
| 48 int32_t bits_per_second); | 50 int32_t bits_per_second); |
| 49 ~VideoTrackRecorder() override; | 51 ~VideoTrackRecorder() override; |
| 50 | 52 |
| 53 void StartFrameEncode(const scoped_refptr<media::VideoFrame>& frame, | |
| 54 base::TimeTicks capture_timestamp); | |
| 51 void Pause(); | 55 void Pause(); |
| 52 void Resume(); | 56 void Resume(); |
| 53 | 57 |
| 54 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, | 58 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, |
| 55 base::TimeTicks capture_time); | 59 base::TimeTicks capture_time); |
| 56 private: | 60 private: |
| 57 friend class VideoTrackRecorderTest; | 61 friend class VideoTrackRecorderTest; |
| 58 | 62 |
| 63 enum Status { | |
| 64 NOT_INITIALIZED, | |
| 65 INITIALIZING, | |
| 66 INITIALIZED, | |
| 67 }; | |
| 68 | |
| 69 void InitializeEncoder(const scoped_refptr<media::VideoFrame>& frame, | |
| 70 base::TimeTicks capture_timestamp); | |
| 71 | |
| 59 // Used to check that we are destroyed on the same thread we were created. | 72 // Used to check that we are destroyed on the same thread we were created. |
| 60 base::ThreadChecker main_render_thread_checker_; | 73 base::ThreadChecker main_render_thread_checker_; |
| 61 | 74 |
| 75 // Used to post initialization on the same thread we were created. | |
| 76 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | |
|
mcasas
2016/05/25 16:42:47
const?
emircan
2016/05/27 04:27:20
Done.
| |
| 77 | |
| 78 // Task runner where frame encode callbacks must happen. | |
| 79 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; | |
| 80 | |
| 81 // Tracks the initialization of the underlying encoder. | |
| 82 Status status_; | |
| 83 | |
| 62 // We need to hold on to the Blink track to remove ourselves on dtor. | 84 // We need to hold on to the Blink track to remove ourselves on dtor. |
| 63 blink::WebMediaStreamTrack track_; | 85 blink::WebMediaStreamTrack track_; |
| 64 | 86 |
| 65 // Inner class to encode using whichever codec is configured. | 87 // Inner class to encode using whichever codec is configured. |
| 66 scoped_refptr<Encoder> encoder_; | 88 scoped_refptr<Encoder> encoder_; |
| 67 | 89 |
| 90 // Parameters that would be passed to the underlying |encoder_|. | |
| 91 const CodecId codec_; | |
| 92 const OnEncodedVideoCB on_encoded_video_callback_; | |
| 93 const int32_t bits_per_second_; | |
| 94 | |
| 95 // Used to track the paused state during the initialization process. | |
| 96 bool paused_; | |
| 97 | |
| 98 base::WeakPtrFactory<VideoTrackRecorder> weak_ptr_factory_; | |
| 99 | |
| 68 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); | 100 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); |
| 69 }; | 101 }; |
| 70 | 102 |
| 71 } // namespace content | 103 } // namespace content |
| 72 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ | 104 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ |
| OLD | NEW |