Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: content/renderer/media/video_track_recorder.h

Issue 1313603004: MediaRecorderHandler (video part) and unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved DCHECK_EQ() Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
12 #include "base/threading/thread_checker.h" 11 #include "base/threading/thread_checker.h"
13 #include "content/public/renderer/media_stream_video_sink.h" 12 #include "content/public/renderer/media_stream_video_sink.h"
14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" 13 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
15 #include "ui/gfx/geometry/size.h" 14 #include "ui/gfx/geometry/size.h"
16 15
17 namespace media { 16 namespace media {
18 class VideoFrame; 17 class VideoFrame;
19 } // namespace media 18 } // namespace media
20 19
21 namespace content { 20 namespace content {
22 21
23 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames 22 // VideoTrackRecorder is a MediaStreamVideoSink that encodes the video frames
24 // received from a Stream Video Track. The class is constructed and used on a 23 // received from a Stream Video Track. The class is constructed and used on a
25 // single thread, namely the main Render thread. It has an internal VpxEncoder 24 // single thread, namely the main Render thread. It has an internal VpxEncoder
26 // that uses a worker thread for encoding. 25 // with its own threading subtleties, see the implementation file. This mirrors
26 // the other MediaStreamVideo* classes that are constructed/configured on Main
27 // Render thread but that pass frames on Render IO thread.
27 class CONTENT_EXPORT VideoTrackRecorder 28 class CONTENT_EXPORT VideoTrackRecorder
28 : NON_EXPORTED_BASE(public MediaStreamVideoSink) { 29 : NON_EXPORTED_BASE(public MediaStreamVideoSink) {
29 public: 30 public:
30 using OnEncodedVideoCB = 31 using OnEncodedVideoCB =
31 base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame, 32 base::Callback<void(const scoped_refptr<media::VideoFrame>& video_frame,
32 const base::StringPiece& encoded_data, 33 const base::StringPiece& encoded_data,
33 base::TimeTicks capture_timestamp, 34 base::TimeTicks capture_timestamp,
34 bool is_key_frame)>; 35 bool is_key_frame)>;
35 36
36 VideoTrackRecorder(const blink::WebMediaStreamTrack& track, 37 VideoTrackRecorder(const blink::WebMediaStreamTrack& track,
37 const OnEncodedVideoCB& on_encoded_video_cb); 38 const OnEncodedVideoCB& on_encoded_video_cb);
38 ~VideoTrackRecorder() override; 39 ~VideoTrackRecorder() override;
39 40
40 void OnVideoFrame(const scoped_refptr<media::VideoFrame>& frame, 41 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame,
41 base::TimeTicks capture_time); 42 base::TimeTicks capture_time);
42 43
43 private: 44 private:
44 friend class VideoTrackRecorderTest; 45 friend class VideoTrackRecorderTest;
45 46
46 // Used to check that we are destroyed on the same thread we were created. 47 // Used to check that we are destroyed on the same thread we were created.
47 base::ThreadChecker main_render_thread_checker_; 48 base::ThreadChecker main_render_thread_checker_;
48 49
49 // We need to hold on to the Blink track to remove ourselves on dtor. 50 // We need to hold on to the Blink track to remove ourselves on dtor.
50 blink::WebMediaStreamTrack track_; 51 blink::WebMediaStreamTrack track_;
51 52
52 // Forward declaration and member of an inner class to encode using VPx. 53 // Forward declaration and member of an inner class to encode using VPx.
53 class VpxEncoder; 54 class VpxEncoder;
54 const scoped_ptr<VpxEncoder> encoder_; 55 const scoped_refptr<VpxEncoder> encoder_;
55
56 base::WeakPtrFactory<VideoTrackRecorder> weak_factory_;
57 56
58 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder); 57 DISALLOW_COPY_AND_ASSIGN(VideoTrackRecorder);
59 }; 58 };
60 59
61 } // namespace content 60 } // namespace content
62 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_ 61 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_RECORDER_H_
OLDNEW
« no previous file with comments | « content/renderer/media/media_recorder_handler_unittest.cc ('k') | content/renderer/media/video_track_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698