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" | |
| 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 |
| 19 namespace base { | |
| 20 class WaitableEvent; | |
| 21 } // namespace base | |
| 22 | |
| 17 namespace media { | 23 namespace media { |
| 18 class VideoFrame; | 24 class VideoFrame; |
| 19 } // namespace media | 25 } // namespace media |
| 20 | 26 |
| 21 namespace content { | 27 namespace content { |
| 22 | 28 |
| 23 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames | 29 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames |
| 24 // received from a Stream Video Track. This class is constructed and used on a | 30 // received from a Stream Video Track. This class is constructed and used on a |
| 25 // single thread, namely the main Render thread. This mirrors the other | 31 // single thread, namely the main Render thread. This mirrors the other |
| 26 // MediaStreamVideo* classes that are constructed/configured on Main Render | 32 // MediaStreamVideo* classes that are constructed/configured on Main Render |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 49 ~VideoTrackRecorder() override; | 55 ~VideoTrackRecorder() override; |
| 50 | 56 |
| 51 void Pause(); | 57 void Pause(); |
| 52 void Resume(); | 58 void Resume(); |
| 53 | 59 |
| 54 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, | 60 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame, |
| 55 base::TimeTicks capture_time); | 61 base::TimeTicks capture_time); |
| 56 private: | 62 private: |
| 57 friend class VideoTrackRecorderTest; | 63 friend class VideoTrackRecorderTest; |
| 58 | 64 |
| 65 void InitializeEncoder(const scoped_refptr<media::VideoFrame>& frame, | |
|
mcasas
2016/06/23 00:27:36
Can we call this method
ReceiveFirstFrameOnIOThrea
emircan
2016/06/28 22:10:41
Done.
| |
| 66 base::TimeTicks capture_time); | |
| 67 void InitializeEncoderTask(const scoped_refptr<media::VideoFrame>& frame, | |
| 68 base::TimeTicks capture_time, | |
| 69 base::WaitableEvent* async_waiter); | |
| 70 | |
| 59 // Used to check that we are destroyed on the same thread we were created. | 71 // Used to check that we are destroyed on the same thread we were created. |
| 60 base::ThreadChecker main_render_thread_checker_; | 72 base::ThreadChecker main_render_thread_checker_; |
| 61 | 73 |
| 74 // Used to post initialization on the same thread we were created. | |
| 75 const scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | |
| 76 | |
| 77 // Task runner where frame encode callbacks must happen. | |
| 78 scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; | |
| 79 | |
| 62 // We need to hold on to the Blink track to remove ourselves on dtor. | 80 // We need to hold on to the Blink track to remove ourselves on dtor. |
| 63 blink::WebMediaStreamTrack track_; | 81 blink::WebMediaStreamTrack track_; |
| 64 | 82 |
| 65 // Inner class to encode using whichever codec is configured. | 83 // Inner class to encode using whichever codec is configured. |
| 66 scoped_refptr<Encoder> encoder_; | 84 scoped_refptr<Encoder> encoder_; |
| 67 | 85 |
| 86 // Parameters that would be passed to the underlying |encoder_|. | |
| 87 const CodecId codec_; | |
| 88 const OnEncodedVideoCB on_encoded_video_callback_; | |
| 89 const int32_t bits_per_second_; | |
| 90 | |
| 91 // Used to track the paused state during the initialization process. | |
| 92 bool paused_before_init_; | |
| 93 | |
| 94 base::WeakPtrFactory<VideoTrackRecorder> weak_ptr_factory_; | |
| 95 | |
| 68 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); | 96 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); |
| 69 }; | 97 }; |
| 70 | 98 |
| 71 } // namespace content | 99 } // namespace content |
| 72 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ | 100 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ |
| OLD | NEW |