1/*
2 *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
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
6 *  tree. An additional intellectual property rights grant can be found
7 *  in the file PATENTS.  All contributing project authors may
8 *  be found in the AUTHORS file in the root of the source tree.
9 */
10
11#if !defined(__has_feature) || !__has_feature(objc_arc)
12#error "This file requires ARC support."
13#endif
14
15#include "webrtc/modules/video_render/ios/video_render_ios_channel.h"
16
17using namespace webrtc;
18
19VideoRenderIosChannel::VideoRenderIosChannel(VideoRenderIosView* view)
20    : view_(view), current_frame_(new VideoFrame()), buffer_is_updated_(false) {
21}
22
23VideoRenderIosChannel::~VideoRenderIosChannel() { delete current_frame_; }
24
25int32_t VideoRenderIosChannel::RenderFrame(const uint32_t stream_id,
26                                           const VideoFrame& video_frame) {
27  current_frame_->CopyFrame(video_frame);
28  current_frame_->set_render_time_ms(0);
29  buffer_is_updated_ = true;
30
31  return 0;
32}
33
34bool VideoRenderIosChannel::RenderOffScreenBuffer() {
35  if (![view_ renderFrame:current_frame_]) {
36    return false;
37  }
38
39  buffer_is_updated_ = false;
40
41  return true;
42}
43
44bool VideoRenderIosChannel::IsUpdated() { return buffer_is_updated_; }
45
46int VideoRenderIosChannel::SetStreamSettings(const float z_order,
47                                             const float left,
48                                             const float top,
49                                             const float right,
50                                             const float bottom) {
51  if (![view_ setCoordinatesForZOrder:z_order
52                                 Left:left
53                                  Top:bottom
54                                Right:right
55                               Bottom:top]) {
56
57    return -1;
58  }
59
60  return 0;
61}
62