136cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org/*
236cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
336cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org *
436cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org *  Use of this source code is governed by a BSD-style license
536cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org *  that can be found in the LICENSE file in the root of the source
636cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org *  tree. An additional intellectual property rights grant can be found
736cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org *  in the file PATENTS.  All contributing project authors may
836cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
936cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org */
1036cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org
11e68102e04666338b7de9d5bc50fc42da197d1c55fischman@webrtc.org#if !defined(__has_feature) || !__has_feature(objc_arc)
12e68102e04666338b7de9d5bc50fc42da197d1c55fischman@webrtc.org#error "This file requires ARC support."
13e68102e04666338b7de9d5bc50fc42da197d1c55fischman@webrtc.org#endif
14e68102e04666338b7de9d5bc50fc42da197d1c55fischman@webrtc.org
1536cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org#include "webrtc/modules/video_render/ios/video_render_ios_channel.h"
1636cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org
1736cf4d2309c394cf458c72c672862223faca008efischman@webrtc.orgusing namespace webrtc;
1836cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org
1936cf4d2309c394cf458c72c672862223faca008efischman@webrtc.orgVideoRenderIosChannel::VideoRenderIosChannel(VideoRenderIosView* view)
204765070b8d6f024509c717c04d9b708750666927Miguel Casas-Sanchez    : view_(view), current_frame_(new VideoFrame()), buffer_is_updated_(false) {
214765070b8d6f024509c717c04d9b708750666927Miguel Casas-Sanchez}
2236cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org
2336cf4d2309c394cf458c72c672862223faca008efischman@webrtc.orgVideoRenderIosChannel::~VideoRenderIosChannel() { delete current_frame_; }
2436cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org
2536cf4d2309c394cf458c72c672862223faca008efischman@webrtc.orgint32_t VideoRenderIosChannel::RenderFrame(const uint32_t stream_id,
264765070b8d6f024509c717c04d9b708750666927Miguel Casas-Sanchez                                           const VideoFrame& video_frame) {
272056ee3e3c7683ae4b2c4b12da99c3105c4f46a9magjed@webrtc.org  current_frame_->CopyFrame(video_frame);
28379069f676c13443398a72f7da8d118c973a0809Magnus Jedvert  current_frame_->set_render_time_ms(0);
2936cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org  buffer_is_updated_ = true;
3036cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org
3136cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org  return 0;
3236cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org}
3336cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org
3436cf4d2309c394cf458c72c672862223faca008efischman@webrtc.orgbool VideoRenderIosChannel::RenderOffScreenBuffer() {
3536cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org  if (![view_ renderFrame:current_frame_]) {
3636cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org    return false;
3736cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org  }
3836cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org
3936cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org  buffer_is_updated_ = false;
4036cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org
4136cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org  return true;
4236cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org}
4336cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org
4436cf4d2309c394cf458c72c672862223faca008efischman@webrtc.orgbool VideoRenderIosChannel::IsUpdated() { return buffer_is_updated_; }
4536cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org
4636cf4d2309c394cf458c72c672862223faca008efischman@webrtc.orgint VideoRenderIosChannel::SetStreamSettings(const float z_order,
4736cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org                                             const float left,
4836cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org                                             const float top,
4936cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org                                             const float right,
5036cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org                                             const float bottom) {
5136cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org  if (![view_ setCoordinatesForZOrder:z_order
5236cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org                                 Left:left
5336cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org                                  Top:bottom
5436cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org                                Right:right
5536cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org                               Bottom:top]) {
5636cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org
5736cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org    return -1;
5836cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org  }
5936cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org
6036cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org  return 0;
6136cf4d2309c394cf458c72c672862223faca008efischman@webrtc.org}
62