Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ | |
| 6 #define CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "base/strings/string_piece.h" | |
| 11 #include "base/threading/thread_checker.h" | |
| 12 #include "content/public/renderer/media_stream_video_sink.h" | |
| 13 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | |
| 14 #include "ui/gfx/geometry/size.h" | |
| 15 | |
| 16 namespace content { | |
| 17 | |
| 18 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames | |
| 19 // received from a Stream Video Track. The class is constructed and used on a | |
| 20 // single thread, namely the main Render thread. It has an internal VpxEncoder | |
| 21 // that uses a worker thread for encoding. | |
| 22 class CONTENT_EXPORT VideoTrackRecorder | |
| 23 : NON_EXPORTED_BASE(public MediaStreamVideoSink) { | |
| 24 public: | |
| 25 using OnEncodedVideoCB = base::Callback<void(const base::StringPiece& data, | |
| 26 base::TimeDelta timestamp, | |
| 27 bool is_key_frame)>; | |
| 28 using OnFirstFrameCB = | |
| 29 base::Callback<OnEncodedVideoCB(const gfx::Size& frame_size, | |
|
miu
2015/08/13 19:32:26
IMO, this is even more complex than before (i.e.,
| |
| 30 double frame_rate)>; | |
| 31 | |
| 32 VideoTrackRecorder(const blink::WebMediaStreamTrack& track, | |
| 33 const OnFirstFrameCB& on_first_frame_cb); | |
| 34 ~VideoTrackRecorder() override; | |
| 35 | |
| 36 private: | |
| 37 friend class VideoTrackRecorderTest; | |
| 38 | |
| 39 // Used to ping |encoder_->StartFrameEncode()| for testing. | |
| 40 void StartFrameEncodeForTesting(const scoped_refptr<media::VideoFrame>& frame, | |
| 41 const base::TimeTicks& capture_time); | |
| 42 | |
| 43 // Used to check that we are destroyed on the same thread we were created. | |
| 44 base::ThreadChecker main_render_thread_checker_; | |
| 45 | |
| 46 // We need to hold on to the Blink track to remove ourselves on dtor. | |
| 47 const blink::WebMediaStreamTrack track_; | |
| 48 | |
| 49 // Forward declaration and member of an inner class to encode using VPx. | |
| 50 class VpxEncoder; | |
| 51 const scoped_refptr<VpxEncoder> encoder_; | |
| 52 | |
| 53 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); | |
| 54 }; | |
| 55 | |
| 56 } // namespace content | |
| 57 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ | |
| OLD | NEW |