modules/video_render/mac/video_render_agl.cc
int VideoChannelAGL::DeliverFrame(const VideoFrame& videoFrame) {
  _owner->LockAGLCntx();

  if (_texture == 0) {
    _owner->UnlockAGLCntx();
    return 0;
  }

  if (CalcBufferSize(kI420, videoFrame.width(), videoFrame.height()) !=
      _incomingBufferSize) {
    _owner->UnlockAGLCntx();
    return -1;
  }

  // Setting stride = width.
  int rgbret = ConvertFromYV12(videoFrame, kBGRA, 0, _buffer);
  if (rgbret < 0) {
    _owner->UnlockAGLCntx();
    return -1;
  }

  aglSetCurrentContext(_aglContext);

  // Put the new frame into the graphic card texture.
  // Make sure this texture is the active one
  glBindTexture(GL_TEXTURE_RECTANGLE_EXT, _texture);
  GLenum glErr = glGetError();
  if (glErr != GL_NO_ERROR) {
    _owner->UnlockAGLCntx();
    return -1;
  }

  // Copy buffer to texture
  glTexSubImage2D(GL_TEXTURE_RECTANGLE_EXT,
                  0, // Level, not use
                  0, // start point x, (low left of pic)
                  0, // start point y,
                  _width, // width
                  _height, // height
                  _pixelFormat, // pictue format for _buffer
                  _pixelDataType, // data type of _buffer
                  (const GLvoid*) _buffer); // the pixel data

  if (glGetError() != GL_NO_ERROR) {
    _owner->UnlockAGLCntx();
    return -1;
  }

  _bufferIsUpdated = true;
  _owner->UnlockAGLCntx();

  return 0;
}
// Called from video engine when a new frame should be rendered.
Called from video engine when a new frame should be rendered.
Called from video engine when a new frame should be rendered .
int VideoChannelAGL::DeliverFrame(const VideoFrame& videoFrame) {
  _owner->LockAGLCntx();
  if (_texture == 0) {
    _owner->UnlockAGLCntx();
    return 0;
  }
  if (CalcBufferSize(kI420, videoFrame.width(), videoFrame.height()) !=
      _incomingBufferSize) {
    _owner->UnlockAGLCntx();
    return -1;
  }
  int rgbret = ConvertFromYV12(videoFrame, kBGRA, 0, _buffer);
  if (rgbret < 0) {
    _owner->UnlockAGLCntx();
    return -1;
  }
  aglSetCurrentContext(_aglContext);
  glBindTexture(GL_TEXTURE_RECTANGLE_EXT, _texture);
  GLenum glErr = glGetError();
  if (glErr != GL_NO_ERROR) {
    _owner->UnlockAGLCntx();
    return -1;
  }
  glTexSubImage2D(GL_TEXTURE_RECTANGLE_EXT,
                  0, 
                  0, 
                  0, 
                  _width, 
                  _height, 
                  _pixelFormat, 
                  _pixelDataType, 
                  (const GLvoid*) _buffer); 
  if (glGetError() != GL_NO_ERROR) {
    _owner->UnlockAGLCntx();
    return -1;
  }
  _bufferIsUpdated = true;
  _owner->UnlockAGLCntx();
  return 0;
}
int VideoChannelAGL :: DeliverFrame ( const VideoFrame & videoFrame ) { _owner -> LockAGLCntx ( ) ; if ( _texture == 0 ) { _owner -> UnlockAGLCntx ( ) ; return 0 ; } if ( CalcBufferSize ( kI420 , videoFrame . width ( ) , videoFrame . height ( ) ) != _incomingBufferSize ) { _owner -> UnlockAGLCntx ( ) ; return -1 ; } int rgbret = ConvertFromYV12 ( videoFrame , kBGRA , 0 , _buffer ) ; if ( rgbret < 0 ) { _owner -> UnlockAGLCntx ( ) ; return -1 ; } aglSetCurrentContext ( _aglContext ) ; glBindTexture ( GL_TEXTURE_RECTANGLE_EXT , _texture ) ; GLenum glErr = glGetError ( ) ; if ( glErr != GL_NO_ERROR ) { _owner -> UnlockAGLCntx ( ) ; return -1 ; } glTexSubImage2D ( GL_TEXTURE_RECTANGLE_EXT , 0 , 0 , 0 , _width , _height , _pixelFormat , _pixelDataType , ( const GLvoid * ) _buffer ) ; if ( glGetError ( ) != GL_NO_ERROR ) { _owner -> UnlockAGLCntx ( ) ; return -1 ; } _bufferIsUpdated = true ; _owner -> UnlockAGLCntx ( ) ; return 0 ; }
Called from video engine when a new frame should be rendered.
Called from video engine when a new frame should be rendered .
// Setting stride = width. // Put the new frame into the graphic card texture. // Make sure this texture is the active one // Copy buffer to texture // Level, not use // start point x, (low left of pic) // start point y, // width // height // pictue format for _buffer // data type of _buffer // the pixel data