| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class VideoAdapter { | 25 class VideoAdapter { |
| 26 public: | 26 public: |
| 27 VideoAdapter(); | 27 VideoAdapter(); |
| 28 virtual ~VideoAdapter(); | 28 virtual ~VideoAdapter(); |
| 29 | 29 |
| 30 // Sets the expected frame interval. This controls how often frames should | 30 // Sets the expected frame interval. This controls how often frames should |
| 31 // be dropped if |OnOutputFormatRequest| is called with a lower frame | 31 // be dropped if |OnOutputFormatRequest| is called with a lower frame |
| 32 // interval. | 32 // interval. |
| 33 void SetExpectedInputFrameInterval(int64_t interval); | 33 void SetExpectedInputFrameInterval(int64_t interval); |
| 34 | 34 |
| 35 // Return the adapted resolution given the input resolution. The returned | 35 // Return the adapted resolution given the input resolution. The input |
| 36 // resolution will be 0x0 if the frame should be dropped. | 36 // resolution should first be cropped to the specified resolution, and then |
| 37 VideoFormat AdaptFrameResolution(int in_width, int in_height); | 37 // scaled to the final output resolution. The output resolution will be 0x0 if |
| 38 // the frame should be dropped. |
| 39 void AdaptFrameResolution(int in_width, |
| 40 int in_height, |
| 41 int* cropped_width, |
| 42 int* cropped_height, |
| 43 int* out_width, |
| 44 int* out_height); |
| 38 | 45 |
| 39 // Requests the output frame size and frame interval from | 46 // Requests the output frame size and frame interval from |
| 40 // |AdaptFrameResolution| to not be larger than |format|. | 47 // |AdaptFrameResolution| to not be larger than |format|. Also, the input |
| 48 // frame size will be cropped to match the requested aspect ratio. The |
| 49 // requested aspect ratio is orientation agnostic and will be adjusted to |
| 50 // maintain the input orientation, so it doesn't matter if e.g. 1280x720 or |
| 51 // 720x1280 is requested. |
| 41 void OnOutputFormatRequest(const VideoFormat& format); | 52 void OnOutputFormatRequest(const VideoFormat& format); |
| 42 | 53 |
| 43 // Requests the output frame size from |AdaptFrameResolution| to not have | 54 // Requests the output frame size from |AdaptFrameResolution| to not have |
| 44 // more than |max_pixel_count| pixels and have "one step" up more pixels than | 55 // more than |max_pixel_count| pixels and have "one step" up more pixels than |
| 45 // max_pixel_count_step_up. | 56 // max_pixel_count_step_up. |
| 46 void OnResolutionRequest(rtc::Optional<int> max_pixel_count, | 57 void OnResolutionRequest(rtc::Optional<int> max_pixel_count, |
| 47 rtc::Optional<int> max_pixel_count_step_up); | 58 rtc::Optional<int> max_pixel_count_step_up); |
| 48 | 59 |
| 49 const VideoFormat& input_format() const; | |
| 50 | |
| 51 private: | 60 private: |
| 52 void SetInputFormat(const VideoFormat& format); | |
| 53 bool Adapt(int max_num_pixels, int max_pixel_count_step_up); | |
| 54 | |
| 55 VideoFormat input_format_; | |
| 56 VideoFormat output_format_; | |
| 57 int output_num_pixels_; | |
| 58 int frames_in_; // Number of input frames. | 61 int frames_in_; // Number of input frames. |
| 59 int frames_out_; // Number of output frames. | 62 int frames_out_; // Number of output frames. |
| 60 int frames_scaled_; // Number of frames scaled. | 63 int frames_scaled_; // Number of frames scaled. |
| 61 int adaption_changes_; // Number of changes in scale factor. | 64 int adaption_changes_; // Number of changes in scale factor. |
| 62 int previous_width_; // Previous adapter output width. | 65 int previous_width_; // Previous adapter output width. |
| 63 int previous_height_; // Previous adapter output height. | 66 int previous_height_; // Previous adapter output height. |
| 64 int64_t interval_next_frame_; | 67 int input_interval_ GUARDED_BY(critical_section_); |
| 68 int64_t interval_next_frame_ GUARDED_BY(critical_section_); |
| 65 | 69 |
| 66 // Max number of pixels requested via calls to OnOutputFormatRequest, | 70 // Max number of pixels requested via calls to OnOutputFormatRequest, |
| 67 // OnResolutionRequest respectively. | 71 // OnResolutionRequest respectively. |
| 68 // The adapted output format is the minimum of these. | 72 // The adapted output format is the minimum of these. |
| 69 int format_request_max_pixel_count_; | 73 rtc::Optional<VideoFormat> requested_format_ GUARDED_BY(critical_section_); |
| 70 int resolution_request_max_pixel_count_; | 74 int resolution_request_max_pixel_count_ GUARDED_BY(critical_section_); |
| 75 int resolution_request_max_pixel_count_step_up_ GUARDED_BY(critical_section_); |
| 71 | 76 |
| 72 // The critical section to protect the above variables. | 77 // The critical section to protect the above variables. |
| 73 rtc::CriticalSection critical_section_; | 78 rtc::CriticalSection critical_section_; |
| 74 | 79 |
| 75 RTC_DISALLOW_COPY_AND_ASSIGN(VideoAdapter); | 80 RTC_DISALLOW_COPY_AND_ASSIGN(VideoAdapter); |
| 76 }; | 81 }; |
| 77 | 82 |
| 78 } // namespace cricket | 83 } // namespace cricket |
| 79 | 84 |
| 80 #endif // WEBRTC_MEDIA_BASE_VIDEOADAPTER_H_ | 85 #endif // WEBRTC_MEDIA_BASE_VIDEOADAPTER_H_ |
| OLD | NEW |