Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
|
mcasas
2014/05/07 14:10:43
I seem to understand from VideoTrackAdapter struct
perkj_chrome
2014/05/08 11:29:47
Not sure what you mean. It can only change the res
| |
| 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, | |
| 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> > | |
|
mcasas
2014/05/07 14:10:43
std::list? Seems that you only used it for push_ba
perkj_chrome
2014/05/08 11:29:47
vector seems to be prefered in Chrome. Its far mor
| |
| 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_ | |
| OLD | NEW |