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

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

Issue 246433006: Change MediaStreamVideoSource to output different resolutions to different tracks depending on the … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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_ADAPTER_H_
6 #define CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_
7
8 #include <vector>
9
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "content/renderer/media/media_stream_video_track.h"
13 #include "media/base/video_frame.h"
14
15 namespace content {
16
17 // VideoTrackAdapter is a helper class used by MediaStreamVideoSource used for
18 // adapting the video resolution from a source implementation to the resolution
19 // a track requires. Different tracks can have different resolution constraints.
20 // The constraints can be set as max width and height as well as max and min
21 // aspect ratio.
22 // Video frames are delivered to a track using a VideoCaptureDeliverFrameCB on
23 // the IO-thread.
24 // Adaptations is done by wrapping the original media::VideoFrame in a new
25 // media::VideoFrame with a new visible_rect and natural_size.
26 class VideoTrackAdapter
27 : public base::RefCountedThreadSafe<VideoTrackAdapter> {
28 public:
29 explicit VideoTrackAdapter(
30 const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
31
32 // Register |track| to receive video frames in |frame_callback| with
33 // a resolution within the boundaries of the arguments.
34 // Must be called on the main render thread.
35 void AddTrack(MediaStreamVideoTrack* track,
perkj_chrome 2014/05/08 11:59:02 const pointer here and below for MediaStreamVideoT
perkj_chrome 2014/05/08 13:36:25 Done.
36 VideoCaptureDeliverFrameCB frame_callback,
37 int max_width, int max_height,
38 double min_aspect_ratio,
39 double max_aspect_ratio);
40 void RemoveTrack(MediaStreamVideoTrack* track);
41
42 // Delivers |frame| to all tracks that have registered a callback.
43 // Must be called on the IO-thread.
44 void DeliverFrameOnIO(
45 const scoped_refptr<media::VideoFrame>& frame,
46 const media::VideoCaptureFormat& format);
47
48 const scoped_refptr<base::MessageLoopProxy>& io_message_loop() {
49 return io_message_loop_;
50 }
51
52 private:
53 virtual ~VideoTrackAdapter();
54 friend class base::RefCountedThreadSafe<VideoTrackAdapter>;
55
56 void AddTrackOnIO(MediaStreamVideoTrack* track,
57 VideoCaptureDeliverFrameCB frame_callback,
58 int max_width, int max_height,
59 double min_aspect_ratio,
60 double max_aspect_ratio);
61 void RemoveTrackOnIO(MediaStreamVideoTrack* track);
62
63 base::ThreadChecker thread_checker_;
64 scoped_refptr<base::MessageLoopProxy> io_message_loop_;
65
66 // VideoFrameResolutionAdapter is an inner class that is created on the main
67 // render thread but operates on the IO-thread. It does the resolution
68 // adaptation and delivers frames to all registered tracks on the IO-thread.
69 class VideoFrameResolutionAdapter;
70 typedef std::vector<scoped_refptr<VideoFrameResolutionAdapter> >
71 FrameAdapters;
72 FrameAdapters adapters_;
73
74 DISALLOW_COPY_AND_ASSIGN(VideoTrackAdapter);
75 };
76
77 } // namespace content
78
79 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698