OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_ADAPTER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_ |
6 #define CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_ | 6 #define CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "content/renderer/media/media_stream_video_track.h" | 15 #include "content/renderer/media/media_stream_video_track.h" |
16 #include "media/base/video_frame.h" | 16 #include "media/base/video_frame.h" |
| 17 #include "ui/gfx/geometry/size.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 struct CONTENT_EXPORT VideoTrackAdapterSettings { | 21 struct CONTENT_EXPORT VideoTrackAdapterSettings { |
21 VideoTrackAdapterSettings(); | 22 VideoTrackAdapterSettings(); |
22 VideoTrackAdapterSettings(int max_width, | 23 VideoTrackAdapterSettings( |
23 int max_height, | 24 int max_width, |
24 double min_aspect_ratio, | 25 int max_height, |
25 double max_aspect_ratio, | 26 double min_aspect_ratio, |
26 double max_frame_rate); | 27 double max_aspect_ratio, |
| 28 double max_frame_rate, |
| 29 const base::Optional<gfx::Size>& expected_native_resolution); |
| 30 VideoTrackAdapterSettings(const VideoTrackAdapterSettings& other); |
| 31 VideoTrackAdapterSettings& operator=(const VideoTrackAdapterSettings& other); |
27 int max_width; | 32 int max_width; |
28 int max_height; | 33 int max_height; |
29 double min_aspect_ratio; | 34 double min_aspect_ratio; |
30 double max_aspect_ratio; | 35 double max_aspect_ratio; |
31 double max_frame_rate; | 36 double max_frame_rate; |
| 37 // If supplied, this can be used to detect frames from a rotated device. |
| 38 base::Optional<gfx::Size> expected_native_size; |
32 }; | 39 }; |
33 | 40 |
34 // VideoTrackAdapter is a helper class used by MediaStreamVideoSource used for | 41 // VideoTrackAdapter is a helper class used by MediaStreamVideoSource used for |
35 // adapting the video resolution from a source implementation to the resolution | 42 // adapting the video resolution from a source implementation to the resolution |
36 // a track requires. Different tracks can have different resolution constraints. | 43 // a track requires. Different tracks can have different resolution constraints. |
37 // The constraints can be set as max width and height as well as max and min | 44 // The constraints can be set as max width and height as well as max and min |
38 // aspect ratio. | 45 // aspect ratio. |
39 // Video frames are delivered to a track using a VideoCaptureDeliverFrameCB on | 46 // Video frames are delivered to a track using a VideoCaptureDeliverFrameCB on |
40 // the IO-thread. | 47 // the IO-thread. |
41 // Adaptations is done by wrapping the original media::VideoFrame in a new | 48 // Adaptations is done by wrapping the original media::VideoFrame in a new |
(...skipping 27 matching lines...) Expand all Loading... |
69 return io_task_runner_.get(); | 76 return io_task_runner_.get(); |
70 } | 77 } |
71 | 78 |
72 // Start monitor that frames are delivered to this object. I.E, that | 79 // Start monitor that frames are delivered to this object. I.E, that |
73 // |DeliverFrameOnIO| is called with a frame rate of |source_frame_rate|. | 80 // |DeliverFrameOnIO| is called with a frame rate of |source_frame_rate|. |
74 // |on_muted_callback| is triggered on the main render thread. | 81 // |on_muted_callback| is triggered on the main render thread. |
75 void StartFrameMonitoring(double source_frame_rate, | 82 void StartFrameMonitoring(double source_frame_rate, |
76 const OnMutedCallback& on_muted_callback); | 83 const OnMutedCallback& on_muted_callback); |
77 void StopFrameMonitoring(); | 84 void StopFrameMonitoring(); |
78 | 85 |
79 static void CalculateTargetSize(const gfx::Size& input_size, | 86 static void CalculateTargetSize(bool is_rotated, |
| 87 const gfx::Size& input_size, |
80 const gfx::Size& max_frame_size, | 88 const gfx::Size& max_frame_size, |
81 double min_aspect_ratio, | 89 double min_aspect_ratio, |
82 double max_aspect_ratio, | 90 double max_aspect_ratio, |
83 gfx::Size* desired_size); | 91 gfx::Size* desired_size); |
84 | 92 |
85 private: | 93 private: |
86 virtual ~VideoTrackAdapter(); | 94 virtual ~VideoTrackAdapter(); |
87 friend class base::RefCountedThreadSafe<VideoTrackAdapter>; | 95 friend class base::RefCountedThreadSafe<VideoTrackAdapter>; |
88 | 96 |
89 void AddTrackOnIO(const MediaStreamVideoTrack* track, | 97 void AddTrackOnIO(const MediaStreamVideoTrack* track, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 139 |
132 // Frame rate configured on the video source, accessed on the IO-thread. | 140 // Frame rate configured on the video source, accessed on the IO-thread. |
133 float source_frame_rate_; | 141 float source_frame_rate_; |
134 | 142 |
135 DISALLOW_COPY_AND_ASSIGN(VideoTrackAdapter); | 143 DISALLOW_COPY_AND_ASSIGN(VideoTrackAdapter); |
136 }; | 144 }; |
137 | 145 |
138 } // namespace content | 146 } // namespace content |
139 | 147 |
140 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_ | 148 #endif // CONTENT_RENDERER_MEDIA_VIDEO_TRACK_ADAPTER_H_ |
OLD | NEW |