Home | History | Annotate | Download | only in ios
      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 
     17 using namespace webrtc;
     18 
     19 VideoRenderIosChannel::VideoRenderIosChannel(VideoRenderIosView* view)
     20     : view_(view),
     21       current_frame_(new I420VideoFrame()),
     22       buffer_is_updated_(false) {}
     23 
     24 VideoRenderIosChannel::~VideoRenderIosChannel() { delete current_frame_; }
     25 
     26 int32_t VideoRenderIosChannel::RenderFrame(const uint32_t stream_id,
     27                                            I420VideoFrame& video_frame) {
     28   video_frame.set_render_time_ms(0);
     29 
     30   current_frame_->CopyFrame(video_frame);
     31   buffer_is_updated_ = true;
     32 
     33   return 0;
     34 }
     35 
     36 bool VideoRenderIosChannel::RenderOffScreenBuffer() {
     37   if (![view_ renderFrame:current_frame_]) {
     38     return false;
     39   }
     40 
     41   buffer_is_updated_ = false;
     42 
     43   return true;
     44 }
     45 
     46 bool VideoRenderIosChannel::IsUpdated() { return buffer_is_updated_; }
     47 
     48 int VideoRenderIosChannel::SetStreamSettings(const float z_order,
     49                                              const float left,
     50                                              const float top,
     51                                              const float right,
     52                                              const float bottom) {
     53   if (![view_ setCoordinatesForZOrder:z_order
     54                                  Left:left
     55                                   Top:bottom
     56                                 Right:right
     57                                Bottom:top]) {
     58 
     59     return -1;
     60   }
     61 
     62   return 0;
     63 }
     64