[prev in list] [next in list] [prev in thread] [next in thread]
List: helix-video-cvs
Subject: [Video-cvs] sitelib/pub/platform/unix/android/3.0
From: xzhao () helixcommunity ! org
Date: 2011-06-14 4:04:15
Message-ID: 201106140404.p5E44I94016195 () mailer ! progressive-comp ! com
[Download RAW message or body]
Update of /cvsroot/video/sitelib/pub/platform/unix/android/3.0
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv21799
Added Files:
Tag: hxclient_3_6_1_atlas
miniandroidsurf_qc8x60.h
Log Message:
Integrate for Android 3.0
--- NEW FILE: miniandroidsurf_qc8x60.h ---
/* ***** BEGIN LICENSE BLOCK *****
* Source last modified: $Id: miniandroidsurf_qc8x60.h,v 1.1.2.1 2011/06/14 04:04:12 \
xzhao Exp $
*
* Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.
*
* The contents of this file, and the files included with this file,
* are subject to the current version of the RealNetworks Public
* Source License (the "RPSL") available at
* http://www.helixcommunity.org/content/rpsl unless you have licensed
* the file under the current version of the RealNetworks Community
* Source License (the "RCSL") available at
* http://www.helixcommunity.org/content/rcsl, in which case the RCSL
* will apply. You may also obtain the license terms directly from
* RealNetworks. You may not use this file except in compliance with
* the RPSL or, if you have a valid RCSL with RealNetworks applicable
* to this file, the RCSL. Please see the applicable RPSL or RCSL for
* the rights, obligations and limitations governing use of the
* contents of the file.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU General Public License Version 2 (the
* "GPL") in which case the provisions of the GPL are applicable
* instead of those above. If you wish to allow use of your version of
* this file only under the terms of the GPL, and not to allow others
* to use your version of this file under the terms of either the RPSL
* or RCSL, indicate your decision by deleting the provisions above
* and replace them with the notice and other provisions required by
* the GPL. If you do not delete the provisions above, a recipient may
* use your version of this file under the terms of any one of the
* RPSL, the RCSL or the GPL.
*
* This file is part of the Helix DNA Technology. RealNetworks is the
* developer of the Original Code and owns the copyrights in the
* portions it created.
*
* This file, and the files included with this file, is distributed
* and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
* ENJOYMENT OR NON-INFRINGEMENT.
*
* Technology Compatibility Kit Test Suite(s) Location:
* http://www.helixcommunity.org/content/tck
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** */
#ifndef _MINIANDROIDSURF_H_
#define _MINIANDROIDSURF_H_
#include "minisurf.h"
#include "minifmt.h"
// undefine helix REF to avoid conflict with android's refcount REF class
#undef REF
#include <hardware/hardware.h>
#include <surfaceflinger/Surface.h>
#include <media/stagefright/MediaBuffer.h>
#include <SoftwareRenderer.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/foundation/ADebug.h>
#include <ui/android_native_buffer.h>
#include <ui/GraphicBuffer.h>
// redefine helix REF for reference parameters
#if defined(__cplusplus)
#define REF(type) type&
#else
#define REF(type) const type * const
#endif
using namespace android;
/*
* This implementation references the video surface rendering design of Stagefright
* Reference: frameworks/base/media/libstagefright/AwesomePlayer.cpp
* Another solution is to directly interact with framebuffer: \
base/libs/ui/FramebufferNativeWindow.cpp
*/
struct HelixRenderer : public RefBase {
HelixRenderer() {}
virtual void render(MediaBuffer *buffer) = 0;
private:
HelixRenderer(const HelixRenderer &);
HelixRenderer &operator=(const HelixRenderer &);
};
// Decoders are instantiated locally and as a consequence
// allocate their buffers in local address space. This renderer
// then performs a color conversion and copy to get the data
// into the ANativeBuffer.
struct HelixLocalRenderer : public HelixRenderer {
HelixLocalRenderer(
const sp<Surface> &surface, const sp<MetaData> &meta)
: mTarget(new SoftwareRenderer(surface, meta)) {
}
virtual void render(MediaBuffer *buffer) {
render((const uint8_t *)buffer->data() + buffer->range_offset(),
buffer->range_length());
}
void render(const void *data, size_t size) {
mTarget->render(data, size, NULL);
}
protected:
virtual ~HelixLocalRenderer() {
delete mTarget;
mTarget = NULL;
}
private:
SoftwareRenderer *mTarget;
HelixLocalRenderer(const HelixLocalRenderer &);
HelixLocalRenderer &operator=(const HelixLocalRenderer &);;
};
// Hardware decoders avoid the CPU color conversion by decoding
// directly to ANativeBuffers, so we must use a renderer that
// just pushes those buffers to the ANativeWindow.
// TODO: We need to add the logic of passing ANativeBuffer to OMX HW decoder. \
About how to dequeue ANativeBuffer buffer, refer to media/stagefright/OMXCodec.cpp: \
OMXCodec::allocateOutputBuffersFromNativeWindow(void *def);
struct HelixNativeWindowRenderer : public HelixRenderer {
HelixNativeWindowRenderer(
const sp<ANativeWindow> &nativeWindow,
int32_t rotationDegrees)
: mNativeWindow(nativeWindow) {
applyRotation(rotationDegrees);
}
virtual void render(MediaBuffer *buffer) {
status_t err = mNativeWindow->queueBuffer(
mNativeWindow.get(), buffer->graphicBuffer().get());
if (err != 0) {
LOGE("queueBuffer failed with error %s (%d)", strerror(-err),
-err);
return;
}
sp<MetaData> metaData = buffer->meta_data();
metaData->setInt32(kKeyRendered, 1);
}
protected:
virtual ~HelixNativeWindowRenderer() {}
private:
sp<ANativeWindow> mNativeWindow;
void applyRotation(int32_t rotationDegrees) {
uint32_t transform;
switch (rotationDegrees) {
case 0: transform = 0; break;
case 90: transform = HAL_TRANSFORM_ROT_90; break;
case 180: transform = HAL_TRANSFORM_ROT_180; break;
case 270: transform = HAL_TRANSFORM_ROT_270; break;
default: transform = 0; break;
}
if (transform) {
CHECK_EQ(0, native_window_set_buffers_transform(
mNativeWindow.get(), transform));
}
}
HelixNativeWindowRenderer(const HelixNativeWindowRenderer &);
HelixNativeWindowRenderer &operator=(
const HelixNativeWindowRenderer &);
};
class CMiniAndroidSurface : public CMiniBaseSurface
{
public:
CMiniAndroidSurface(IUnknown* pContext, CMiniBaseSite* pSite);
virtual ~CMiniAndroidSurface();
virtual HX_RESULT _CreateDestBuffer(int cidIn, int nWidth, int nHeight, int& \
nCount);
virtual HX_RESULT _LockDestBuffer(UCHAR** ppDestPtr,
LONG32* pnDestPitch,
int& cid,
REF(HXxSize) srcSize,
int nIndex=0);
virtual HX_RESULT _TransferToDestBuffer(UCHAR* pSrcBuffer,
HXBitmapInfoHeader* pBitmapInfo,
HXxRect* prSrcRect,
HXxRect* prDstRect,
UCHAR* pDstBuffer,
LONG32 nDstPitch);
virtual HX_RESULT _UnlockDestBuffer(UCHAR* pSurfPtr, int nIndex=0);
virtual HX_RESULT _RenderDestBuffer(HXxRect* prSrcRect,
HXxRect* prDstRect,
int nIndex=0);
virtual HX_RESULT _DestroyDestBuffer(int cid, int nCount=1);
protected:
virtual int GetDstCID(int cidIn);
virtual void SetSrcCID(int cidIn) { m_cidIn = cidIn; }
private:
int m_cidIn;
int m_cidOut;
int m_nCompositionPitch;
UINT32 m_ulFrameSize;
sp<HelixRenderer> mVideoRenderer;
sp<Surface> m_pSurface; // Android UI surface to render to
HXBOOL m_bInEmulator; // affect supported surface pixel format
int m_ratationDegree;
sp<MetaData> m_MetaData;
HX_RESULT GetSurface(void);
HX_RESULT InitViedoRender();
int m_nStride;
int m_nWidth;
int m_nHeight;
int m_ifmt;
};
#endif //_MINIANDROIDSURF_H_
_______________________________________________
Video-cvs mailing list
Video-cvs@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/video-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic