[Player-cvs] kit/jsr135 datasourceadapter.cpp, NONE, 1.1 Umakefil, 1.9, 1.10 manager.cpp, 1.8, 1.9 manager_wrap.cpp, 1.13, 1.14 mmapi.i, 1.10, 1.11 player.cpp, 1.13, 1.14

[Player-cvs] kit/jsr135 datasourceadapter.cpp, NONE, 1.1 Umakefil, 1.9, 1.10 manager.cpp, 1.8, 1.9 manager_wrap.cpp, 1.13, 1.14 mmapi.i, 1.10, 1.11 player.cpp, 1.13, 1.14

cdunn at helixcommunity.org cdunn at helixcommunity.org
Thu Mar 9 17:21:03 PST 2006


Update of /cvsroot/player/kit/jsr135
In directory cvs:/tmp/cvs-serv2605

Modified Files:
	Umakefil manager.cpp manager_wrap.cpp mmapi.i player.cpp 
Added Files:
	datasourceadapter.cpp 
Log Message:
New DataSource arch

--- NEW FILE: datasourceadapter.cpp ---
/* ***** BEGIN LICENSE BLOCK ***** 
 * Version: RCSL 1.0/RPSL 1.0 
 *  
 * Portions Copyright (c) 1995-2002 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 
 * Version 1.0 (the "RPSL") available at 
 * http://www.helixcommunity.org/content/rpsl unless you have licensed 
 * the file under the RealNetworks Community Source License Version 1.0 
 * (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.  
 *  
 * 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 ***** */ 

#include "hxcom.h"
#include "hxtypes.h"
#include "hxengin.h"
#include "hxcomm.h"
#include "hxcore.h"
#include "hxfiles.h"
#include "hxdataf.h"
#include "pckunpck.h"
#include "hxsimpleringbuf.h"
#include "datasourceadapter.h"

_DataSourceAdapter::_DataSourceAdapter(char* locator, bool bIsMimeType)
	: m_locator((const char*) locator)
	, m_bIsMimeType(bIsMimeType)
	, m_lRefCount(0)
	, m_pRingBuffer(NULL)
	, m_pRequestQueue(NULL)
{
    // Create a ring 256K buffer, and 32K reserve
    m_pRingBuffer = new HXSimpleRingBuffer(1024*256, 1024*32);
    m_pRequestQueue = new CHXSimpleList;
    if (m_bIsMimeType)
    {
	    m_type = m_locator;
	    m_locator = "fileproxy://" + m_locator;
    }
}

_DataSourceAdapter::~_DataSourceAdapter()
{
    HX_DELETE(m_pRingBuffer);
    HX_DELETE(m_pRequestQueue);
}

long
_DataSourceAdapter::getOffset()
{
    return m_pRingBuffer->getOffset();
}

void
_DataSourceAdapter::storeData(unsigned char* buf, int buflen)
{
    m_pRingBuffer->Put(buf, buflen);
}

bool
_DataSourceAdapter::IsRingBufferFull(INT32 lLen)
{
    return m_pRingBuffer->IsFull(lLen);
}

/*
// Get a request from the queue
int
_DataSourceAdapter::getRequest()
{
    if (m_pRequestQueue->IsEmpty())
	return 0;
    int req = (int)m_pRequestQueue->RemoveHead();
    return req;
}
*/

int
_DataSourceAdapter::getRingBufferState()
{
	return (int)m_pRingBuffer->getState();
}

/////////////////////////////////////////////////////////////////////////
//  Method:
//	IUnknown::QueryInterface
//  Purpose:
//	Implement this to export the interfaces supported by your 
//	object.
//
STDMETHODIMP _DataSourceAdapter::QueryInterface(REFIID riid, void** ppvObj)
{
    if (IsEqualIID(riid, IID_IHXDataFile))
    {
        AddRef();
        *ppvObj = (IHXDataFile*)this;
        return HXR_OK;
    }
    if (m_bIsMimeType && IsEqualIID(IID_IHXFileMimeMapper, riid))
    {
        AddRef();
        *ppvObj = (IHXFileMimeMapper*)(this);
        return HXR_OK;
    }
	
    *ppvObj = NULL;
    return HXR_NOINTERFACE;
}

/////////////////////////////////////////////////////////////////////////
//  Method:
//	IUnknown::AddRef
//  Purpose:
//	Everyone usually implements this the same... feel free to use
//	this implementation.
//
STDMETHODIMP_(ULONG32) _DataSourceAdapter::AddRef()
{
    return InterlockedIncrement(&m_lRefCount);
}

/////////////////////////////////////////////////////////////////////////
//  Method:
//	IUnknown::Release
//  Purpose:
//	Everyone usually implements this the same... feel free to use
//	this implementation.
//
STDMETHODIMP_(ULONG32) _DataSourceAdapter::Release()
{
    if (InterlockedDecrement(&m_lRefCount) > 0)
    {
        return m_lRefCount;
    }

    delete this;
    return 0;
}


/*
 *  IHXDataFile methods
 */

/* Bind DataFile Object with FileName */
STDMETHODIMP_(void)
_DataSourceAdapter::Bind(const char* pFilename)
{
    //m_locator = pFilename; //->Set((BYTE *)pFilename, strlen(pFilename)+1);
}


/* Creates a datafile using the specified mode
 * uOpenMode --- File Open mode - HX_FILEFLAG_READ/HX_FILEFLAG_WRITE/HX_FILEFLAG_BINARY
 */
STDMETHODIMP
_DataSourceAdapter::Open(UINT16 uOpenMode)
{
    return 0;
}

STDMETHODIMP
_DataSourceAdapter::Create(UINT16 uOpenMode)
{
    return 0;
}



/* Close closes a file 
 * If the reference count on the IHXDataFile object is greater than 1, 
 * then the underlying file cannot be safely closed, so Close() becomes 
 * a noop in that case. Close it only when the object is destroyed. 
 * This would be safe, but could lead to a file descriptor leak.
 */
STDMETHODIMP
_DataSourceAdapter::Close()
{
    return HXR_OK;
}


/* Name returns the currently bound file name in FileName.
 * and returns TRUE, if the a name has been bound.  Otherwise
 * FALSE is returned.
 */
STDMETHODIMP_(HXBOOL)
_DataSourceAdapter::Name(REF(IHXBuffer*) pFileName)
{
    HXBOOL bRetVal = FALSE;
    return bRetVal;
}


/*
 * IsOpen returns TRUE if file is open.  Otherwise FALSE.
 */
inline HXBOOL
_DataSourceAdapter::IsOpen()
{
    return FALSE; //(m_pFile ? TRUE : FALSE);
}


/* Seek moves the current file position to the offset from the
 * fromWhere specifier returns current position of file or -1 on
 * error.
 */
STDMETHODIMP
_DataSourceAdapter::Seek(ULONG32 offset, UINT16 fromWhere)
{
    m_pRingBuffer->Seek(offset);
    return HXR_OK;
}


/* Tell returns the current file position in the file */
STDMETHODIMP_(ULONG32)
_DataSourceAdapter::Tell()
{
    return (ULONG32) m_pRingBuffer->getOffset();
}


/* Read reads up to count bytes of data into buf.
 * returns the number of bytes read, EOF, or -1 if the read failed 
 */
STDMETHODIMP_(ULONG32)
_DataSourceAdapter::Read(REF(IHXBuffer*) pOutBuf, ULONG32 count)
{
    ULONG32 ncnt = 0;           // number of bytes read
    IHXBuffer* pBuf = NULL;
    INT32 uCount = count;

    CreateBufferCCF(pOutBuf, m_pEngine);
    pOutBuf->SetSize(count);
    if (m_pRingBuffer->Get(pOutBuf->GetBuffer(), uCount) == TRUE)
    {
	ncnt = (ULONG32) count;
    }
    else
    {
	HX_DELETE(pOutBuf);
    }

    return ncnt;
}


/* Write writes up to count bytes of data from buf.
 * returns the number of bytes written, or -1 if the write failed 
 */
STDMETHODIMP_(ULONG32)
_DataSourceAdapter::Write(REF(IHXBuffer *) pBuf)
{
    return -1;
}


/* Flush out the data in case of Buffered I/O
 */
STDMETHODIMP
_DataSourceAdapter::Flush()
{
    return HXR_INVALID_FILE;
}


/*
 * Return info about the data file such as permissions, time of creation
 * size in bytes, etc.
 */
STDMETHODIMP
_DataSourceAdapter::Stat(struct stat* statbuf)
{
    return HXR_FAIL;
}


/* Return the file descriptor */
inline INT16
_DataSourceAdapter::GetFd()
{
    return 0;
}


/* GetLastError returns the platform specific file error */
STDMETHODIMP
_DataSourceAdapter::GetLastError()
{
    return 0; //m_ulLastError;
}


/* GetLastError returns the platform specific file error in
 * string form.
 */
STDMETHODIMP_(void)
_DataSourceAdapter::GetLastError(REF(IHXBuffer*) err)
{
}

STDMETHODIMP
_DataSourceAdapter::Delete()
{
    Close();

    return HXR_FAIL;
}

/************************************************************************
 *	Method:
 *	    IHXFileMimeMapper::FindMimeType
 */
STDMETHODIMP
_DataSourceAdapter::FindMimeType(const char* pURL, IHXFileMimeMapperResponse* pMimeMapperResponse)
{
    HX_RESULT hResult = (m_bIsMimeType) ? HXR_OK : HXR_FAIL;

    pMimeMapperResponse->MimeTypeFound(hResult, m_type);

    return hResult;
}


Index: mmapi.i
===================================================================
RCS file: /cvsroot/player/kit/jsr135/mmapi.i,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- mmapi.i	4 Mar 2006 00:54:07 -0000	1.10
+++ mmapi.i	10 Mar 2006 01:20:59 -0000	1.11
@@ -3,7 +3,7 @@
  /* Includes the header in the wrapper code */
  #include "manager.h"
  #include "player.h"
- #include "datasource.h"
+ #include "datasourceadapter.h"
  #include "volumecontrol.h"
  #include "videocontrol.h"
  #include "guicontrol.h"
@@ -129,7 +129,7 @@
 }
 
  %include "pub/player.h"
- %include "pub/datasource.h"
+ %include "pub/datasourceadapter.h"
  %include "pub/volumecontrol.h"
  %include "pub/videocontrol.h"
  %include "pub/guicontrol.h"

Index: manager_wrap.cpp
===================================================================
RCS file: /cvsroot/player/kit/jsr135/manager_wrap.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- manager_wrap.cpp	8 Mar 2006 22:07:54 -0000	1.13
+++ manager_wrap.cpp	10 Mar 2006 01:20:59 -0000	1.14
@@ -161,7 +161,7 @@
  /* Includes the header in the wrapper code */
  #include "manager.h"
  #include "player.h"
- #include "datasource.h"
+ #include "datasourceadapter.h"
  #include "volumecontrol.h"
  #include "videocontrol.h"
  #include "guicontrol.h"
@@ -236,12 +236,12 @@
 
 JNIEXPORT jlong JNICALL Java_javax_microedition_media_mmapiJNI__1Manager_1createPlayer_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1) {
     jlong jresult = 0 ;
-    _DataSource *arg1 = (_DataSource *) 0 ;
+    _DataSourceAdapter *arg1 = (_DataSourceAdapter *) 0 ;
     _Player *result;
     
     (void)jenv;
     (void)jcls;
-    arg1 = *(_DataSource **)(void *)&jarg1; 
+    arg1 = *(_DataSourceAdapter **)(void *)&jarg1; 
     {
         try {
             result = (_Player *)_Manager::createPlayer(arg1);
@@ -400,13 +400,13 @@
 JNIEXPORT jlong JNICALL Java_javax_microedition_media_mmapiJNI_new_1_1Player_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) {
     jlong jresult = 0 ;
     IHXClientEngine *arg1 = (IHXClientEngine *) 0 ;
-    _DataSource *arg2 = (_DataSource *) 0 ;
+    _DataSourceAdapter *arg2 = (_DataSourceAdapter *) 0 ;
     _Player *result;
     
     (void)jenv;
     (void)jcls;
     arg1 = *(IHXClientEngine **)(void *)&jarg1; 
-    arg2 = *(_DataSource **)(void *)&jarg2; 
+    arg2 = *(_DataSourceAdapter **)(void *)&jarg2; 
     result = (_Player *)new _Player(arg1,arg2);
     
     *(_Player **)(void *)&jresult = result; 
@@ -733,21 +733,6 @@
 }
 
 
-JNIEXPORT jlong JNICALL Java_javax_microedition_media_mmapiJNI__1Player_1getDataSource(JNIEnv *jenv, jclass jcls, jlong jarg1) {
-    jlong jresult = 0 ;
-    _Player *arg1 = (_Player *) 0 ;
-    _DataSource *result;
-    
-    (void)jenv;
-    (void)jcls;
-    arg1 = *(_Player **)(void *)&jarg1; 
-    result = (_DataSource *)(arg1)->getDataSource();
-    
-    *(_DataSource **)(void *)&jresult = result; 
-    return jresult;
-}
-
-
 JNIEXPORT jlong JNICALL Java_javax_microedition_media_mmapiJNI__1Player_1getVolumeControl(JNIEnv *jenv, jclass jcls, jlong jarg1) {
     jlong jresult = 0 ;
     _Player *arg1 = (_Player *) 0 ;
@@ -926,11 +911,11 @@
 }
 
 
-JNIEXPORT jlong JNICALL Java_javax_microedition_media_mmapiJNI_new_1_1DataSource(JNIEnv *jenv, jclass jcls, jstring jarg1, jboolean jarg2) {
+JNIEXPORT jlong JNICALL Java_javax_microedition_media_mmapiJNI_new_1_1DataSourceAdapter(JNIEnv *jenv, jclass jcls, jstring jarg1, jboolean jarg2) {
     jlong jresult = 0 ;
     char *arg1 = (char *) 0 ;
     bool arg2 ;
-    _DataSource *result;
+    _DataSourceAdapter *result;
     
     (void)jenv;
     (void)jcls;
@@ -942,9 +927,9 @@
         }
     }
     arg2 = jarg2 ? true : false; 
-    result = (_DataSource *)new _DataSource(arg1,arg2);
+    result = (_DataSourceAdapter *)new _DataSourceAdapter(arg1,arg2);
     
-    *(_DataSource **)(void *)&jresult = result; 
+    *(_DataSourceAdapter **)(void *)&jresult = result; 
     {
         if (arg1) jenv->ReleaseStringUTFChars(jarg1, arg1); 
     }
@@ -952,25 +937,25 @@
 }
 
 
-JNIEXPORT void JNICALL Java_javax_microedition_media_mmapiJNI_delete_1_1DataSource(JNIEnv *jenv, jclass jcls, jlong jarg1) {
-    _DataSource *arg1 = (_DataSource *) 0 ;
+JNIEXPORT void JNICALL Java_javax_microedition_media_mmapiJNI_delete_1_1DataSourceAdapter(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+    _DataSourceAdapter *arg1 = (_DataSourceAdapter *) 0 ;
     
     (void)jenv;
     (void)jcls;
-    arg1 = *(_DataSource **)(void *)&jarg1; 
+    arg1 = *(_DataSourceAdapter **)(void *)&jarg1; 
     delete arg1;
     
 }
 
 
-JNIEXPORT jstring JNICALL Java_javax_microedition_media_mmapiJNI__1DataSource_1getLocator(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+JNIEXPORT jstring JNICALL Java_javax_microedition_media_mmapiJNI__1DataSourceAdapter_1getLocator(JNIEnv *jenv, jclass jcls, jlong jarg1) {
     jstring jresult = 0 ;
-    _DataSource *arg1 = (_DataSource *) 0 ;
+    _DataSourceAdapter *arg1 = (_DataSourceAdapter *) 0 ;
     char *result;
     
     (void)jenv;
     (void)jcls;
-    arg1 = *(_DataSource **)(void *)&jarg1; 
+    arg1 = *(_DataSourceAdapter **)(void *)&jarg1; 
     result = (char *)(arg1)->getLocator();
     
     {
@@ -980,100 +965,15 @@
 }
 
 
-JNIEXPORT jstring JNICALL Java_javax_microedition_media_mmapiJNI__1DataSource_1getContentType(JNIEnv *jenv, jclass jcls, jlong jarg1) {
-    jstring jresult = 0 ;
-    _DataSource *arg1 = (_DataSource *) 0 ;
-    char *result;
-    
-    (void)jenv;
-    (void)jcls;
-    arg1 = *(_DataSource **)(void *)&jarg1; 
-    result = (char *)(arg1)->getContentType();
-    
-    {
-        if(result) jresult = jenv->NewStringUTF(result); 
-    }
-    return jresult;
-}
-
-
-JNIEXPORT void JNICALL Java_javax_microedition_media_mmapiJNI__1DataSource_1connect(JNIEnv *jenv, jclass jcls, jlong jarg1) {
-    _DataSource *arg1 = (_DataSource *) 0 ;
-    
-    (void)jenv;
-    (void)jcls;
-    arg1 = *(_DataSource **)(void *)&jarg1; 
-    (arg1)->connect();
-    
-}
-
-
-JNIEXPORT void JNICALL Java_javax_microedition_media_mmapiJNI__1DataSource_1disconnect(JNIEnv *jenv, jclass jcls, jlong jarg1) {
-    _DataSource *arg1 = (_DataSource *) 0 ;
-    
-    (void)jenv;
-    (void)jcls;
-    arg1 = *(_DataSource **)(void *)&jarg1; 
-    (arg1)->disconnect();
-    
-}
-
-
-JNIEXPORT void JNICALL Java_javax_microedition_media_mmapiJNI__1DataSource_1start(JNIEnv *jenv, jclass jcls, jlong jarg1) {
-    _DataSource *arg1 = (_DataSource *) 0 ;
-    
-    (void)jenv;
-    (void)jcls;
-    arg1 = *(_DataSource **)(void *)&jarg1; 
-    {
-        try {
-            (arg1)->start();
-            
-        } catch (_MediaException &me) {
-            jclass clazz = jenv->FindClass("javax/microedition/media/MediaException");
-            if (clazz) jenv->ThrowNew(clazz, me.getMessage());
-            return ;
-        } catch (_IllegalStateException& ise) {
-            jclass clazz = jenv->FindClass("java/lang/IllegalStateException");
-            if (clazz) jenv->ThrowNew(clazz, ise.getMessage());
-            return ;
-        }
-    }
-}
-
-
-JNIEXPORT void JNICALL Java_javax_microedition_media_mmapiJNI__1DataSource_1stop(JNIEnv *jenv, jclass jcls, jlong jarg1) {
-    _DataSource *arg1 = (_DataSource *) 0 ;
-    
-    (void)jenv;
-    (void)jcls;
-    arg1 = *(_DataSource **)(void *)&jarg1; 
-    {
-        try {
-            (arg1)->stop();
-            
-        } catch (_MediaException &me) {
-            jclass clazz = jenv->FindClass("javax/microedition/media/MediaException");
-            if (clazz) jenv->ThrowNew(clazz, me.getMessage());
-            return ;
-        } catch (_IllegalStateException& ise) {
-            jclass clazz = jenv->FindClass("java/lang/IllegalStateException");
-            if (clazz) jenv->ThrowNew(clazz, ise.getMessage());
-            return ;
-        }
-    }
-}
-
-
-JNIEXPORT jboolean JNICALL Java_javax_microedition_media_mmapiJNI__1DataSource_1IsRingBufferFull(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) {
+JNIEXPORT jboolean JNICALL Java_javax_microedition_media_mmapiJNI__1DataSourceAdapter_1IsRingBufferFull(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) {
     jboolean jresult = 0 ;
-    _DataSource *arg1 = (_DataSource *) 0 ;
+    _DataSourceAdapter *arg1 = (_DataSourceAdapter *) 0 ;
     long arg2 ;
     bool result;
     
     (void)jenv;
     (void)jcls;
-    arg1 = *(_DataSource **)(void *)&jarg1; 
+    arg1 = *(_DataSourceAdapter **)(void *)&jarg1; 
     arg2 = (long)jarg2; 
     result = (bool)(arg1)->IsRingBufferFull(arg2);
     
@@ -1082,14 +982,14 @@
 }
 
 
-JNIEXPORT void JNICALL Java_javax_microedition_media_mmapiJNI__1DataSource_1storeData(JNIEnv *jenv, jclass jcls, jlong jarg1, jbyteArray jarg2, jint jarg3) {
-    _DataSource *arg1 = (_DataSource *) 0 ;
+JNIEXPORT void JNICALL Java_javax_microedition_media_mmapiJNI__1DataSourceAdapter_1storeData(JNIEnv *jenv, jclass jcls, jlong jarg1, jbyteArray jarg2, jint jarg3) {
+    _DataSourceAdapter *arg1 = (_DataSourceAdapter *) 0 ;
     unsigned char *arg2 = (unsigned char *) 0 ;
     int arg3 ;
     
     (void)jenv;
     (void)jcls;
-    arg1 = *(_DataSource **)(void *)&jarg1; 
+    arg1 = *(_DataSourceAdapter **)(void *)&jarg1; 
     {
         arg2 = (unsigned char* ) jenv->GetByteArrayElements(jarg2, 0); 
     }
@@ -1099,57 +999,42 @@
 }
 
 
-JNIEXPORT jlong JNICALL Java_javax_microedition_media_mmapiJNI__1DataSource_1getRequest(JNIEnv *jenv, jclass jcls, jlong jarg1) {
-    jlong jresult = 0 ;
-    _DataSource *arg1 = (_DataSource *) 0 ;
-    EDataSource result;
-    
-    (void)jenv;
-    (void)jcls;
-    arg1 = *(_DataSource **)(void *)&jarg1; 
-    result = (arg1)->getRequest();
-    
-    *(EDataSource **)(void *)&jresult = new EDataSource((EDataSource &)result); 
-    return jresult;
-}
-
-
-JNIEXPORT jint JNICALL Java_javax_microedition_media_mmapiJNI__1DataSource_1getState(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+JNIEXPORT jint JNICALL Java_javax_microedition_media_mmapiJNI__1DataSourceAdapter_1getRingBufferState(JNIEnv *jenv, jclass jcls, jlong jarg1) {
     jint jresult = 0 ;
-    _DataSource *arg1 = (_DataSource *) 0 ;
+    _DataSourceAdapter *arg1 = (_DataSourceAdapter *) 0 ;
     int result;
     
     (void)jenv;
     (void)jcls;
-    arg1 = *(_DataSource **)(void *)&jarg1; 
-    result = (int)(arg1)->getState();
+    arg1 = *(_DataSourceAdapter **)(void *)&jarg1; 
+    result = (int)(arg1)->getRingBufferState();
     
     jresult = (jint)result; 
     return jresult;
 }
 
 
-JNIEXPORT void JNICALL Java_javax_microedition_media_mmapiJNI__1DataSource_1setState(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) {
-    _DataSource *arg1 = (_DataSource *) 0 ;
+JNIEXPORT void JNICALL Java_javax_microedition_media_mmapiJNI__1DataSourceAdapter_1setRingBufferState(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) {
+    _DataSourceAdapter *arg1 = (_DataSourceAdapter *) 0 ;
     int arg2 ;
     
     (void)jenv;
     (void)jcls;
-    arg1 = *(_DataSource **)(void *)&jarg1; 
+    arg1 = *(_DataSourceAdapter **)(void *)&jarg1; 
     arg2 = (int)jarg2; 
-    (arg1)->setState(arg2);
+    (arg1)->setRingBufferState(arg2);
     
 }
 
 
-JNIEXPORT jint JNICALL Java_javax_microedition_media_mmapiJNI__1DataSource_1getOffset(JNIEnv *jenv, jclass jcls, jlong jarg1) {
+JNIEXPORT jint JNICALL Java_javax_microedition_media_mmapiJNI__1DataSourceAdapter_1getOffset(JNIEnv *jenv, jclass jcls, jlong jarg1) {
     jint jresult = 0 ;
-    _DataSource *arg1 = (_DataSource *) 0 ;
+    _DataSourceAdapter *arg1 = (_DataSourceAdapter *) 0 ;
     long result;
     
     (void)jenv;
     (void)jcls;
-    arg1 = *(_DataSource **)(void *)&jarg1; 
+    arg1 = *(_DataSourceAdapter **)(void *)&jarg1; 
     result = (long)(arg1)->getOffset();
     
     jresult = (jint)result; 

Index: player.cpp
===================================================================
RCS file: /cvsroot/player/kit/jsr135/player.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- player.cpp	8 Mar 2006 22:07:54 -0000	1.13
+++ player.cpp	10 Mar 2006 01:20:59 -0000	1.14
@@ -51,7 +51,7 @@
 #include "hxstring.h"
 #include "hlxclib/string.h"
 #include "hxstrutl.h"
-#include "datasource.h"
+#include "datasourceadapter.h"
 
 #include "hxcom.h"
 #include "hxcomm.h"
@@ -76,19 +76,30 @@
 _Player::_Player(IHXClientEngine* pClientEngine, char* locator) :
 		m_pClientEngine(pClientEngine),
     		m_url((const char*)locator),
-		m_pDataSource(NULL)
+		m_pDataSourceAdapter(NULL)
 {
     printf("_Player:_Player(%s)\n", locator);
     InitPlayer();
 }
 
-_Player::_Player(IHXClientEngine* pClientEngine, _DataSource* pDataSource) :
+_Player::_Player(IHXClientEngine* pClientEngine, _DataSourceAdapter* pDataSourceAdapter) :
 		m_pClientEngine(pClientEngine),
-		m_pDataSource(pDataSource)
+		m_pDataSourceAdapter(pDataSourceAdapter)
 {
-    printf("_Player:_Player(DataSource)\n");
+    printf("_Player:_Player(DataSourceAdapter)\n");
     InitPlayer();
-    m_pDataSource->setPlayer(m_pPlayer);
+
+    IHXCommonClassFactory* pCCF = NULL;
+    if (m_pClientEngine &&
+        HXR_OK == m_pClientEngine->QueryInterface(IID_IHXCommonClassFactory, (void**)&pCCF))
+    {
+	pCCF->CreateInstance(CLSID_IHXRequest, (void**)&m_pRequest);
+    }
+    HX_RELEASE(pCCF);
+
+    m_pDataSourceAdapter->setEngine(m_pClientEngine);
+
+    m_url = m_pDataSourceAdapter->getLocator(); // used in m_pRequest->SetURL
 }
 
 void
@@ -97,6 +108,7 @@
     m_pPlayer = NULL; 
     m_pClientState = NULL;
     m_pContext = NULL;
+    m_pRequest = NULL;
     m_state = UNREALIZED;
     m_eTransState = TransState_Idle;
     m_pCreatePlayerCallback = NULL;
@@ -117,7 +129,7 @@
     m_pGUIControl = NULL;
     m_pTimeBase = NULL;
     m_pGroupManager = NULL;
-    m_bUsingProxy = (m_pDataSource) ? TRUE : FALSE;
+    m_bProxyMode = (m_pDataSourceAdapter) ? TRUE : FALSE;
     m_ulLoopCount = 1;
 
     if (m_pClientEngine && m_pClientEngine->QueryInterface(IID_IHXScheduler, (void**)&m_pScheduler) != HXR_OK)
@@ -181,8 +193,9 @@
     HX_DELETE(m_pTimeBase);
     HX_RELEASE(m_pClientState);
     HX_DELETE(m_pMutex);
-    HX_DELETE(m_pDataSource);
+    HX_DELETE(m_pDataSourceAdapter);
     HX_DELETE(m_pCreatePlayerEvent);
+    HX_RELEASE(m_pRequest);
 
     for (int i=0; i<TransState_Count; i++)
     {
@@ -539,21 +552,42 @@
 	throw _IllegalStateException("Player is in the CLOSED state");
     }
 
+    HX_RESULT res=HXR_OK;
+
     // open the url
     if (m_pPlayer)
     {
-	// Prepend "file://" if no protocol was specified
-	if( m_url.Find("://") < 0)
+	if (m_bProxyMode)
 	{
-	    m_url = "file://" + m_url;
-	}
+	    m_pRequest->SetURL(m_url);
 
-	if (m_bUsingProxy)
+	    IHXRequestContext *pRequestContext = NULL;
+	    m_pRequest->QueryInterface(IID_IHXRequestContext, (void**)&pRequestContext);
+	    if(pRequestContext)
+	    {
+		pRequestContext->SetRequester((IHXDataFile*)m_pDataSourceAdapter);
+		HX_RELEASE(pRequestContext);
+	    }
+
+	    IHXPlayer2* pPlayer2=NULL;
+	    HX_RESULT res = m_pPlayer->QueryInterface(IID_IHXPlayer2, (void**)&pPlayer2);
+	    if(SUCCEEDED(res))
+	    {
+		pPlayer2->OpenRequest(m_pRequest);
+		HX_RELEASE(pPlayer2);
+	    }
+	}
+	else
 	{
-		m_pDataSource->connect();
-		m_pDataSource->start(); // initiate data transfer
+	    // Prepend "file://" if no protocol was specified
+	    if( m_url.Find("://") < 0)
+	    {
+	        m_url = "file://" + m_url;
+	    }
+	    res = m_pPlayer->OpenURL(m_url);
 	}
-	else if (m_pPlayer->OpenURL(m_url) != HXR_OK)
+
+	if (!SUCCEEDED(res))
 	{
 	    // If there was an error unblock
 	    Unblock(TransState_Realizing);
@@ -834,9 +868,9 @@
 	return;
     }
 
-    if (m_pDataSource)
+    if (m_pDataSourceAdapter)
     {
-	m_pDataSource->disconnect();
+	//m_pDataSourceAdapter->disconnect();
     }
 
     TransitionToState(TransState_Closing);
@@ -1038,12 +1072,6 @@
     return "not implemented";
 }
 
-_DataSource* 
-_Player::getDataSource()
-{
-    return m_pDataSource;
-}
-
 // JNI-friendly version
 _VolumeControl*
 _Player::getVolumeControl()
@@ -1823,3 +1851,4 @@
 	printf("NOT_SUPPORTED: Player::setTimeBase\n");
 }
 
+

Index: manager.cpp
===================================================================
RCS file: /cvsroot/player/kit/jsr135/manager.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- manager.cpp	8 Mar 2006 22:07:54 -0000	1.8
+++ manager.cpp	10 Mar 2006 01:20:59 -0000	1.9
@@ -146,11 +146,11 @@
     return p;
 }
 
-// Create a Player from a DataSource
+// Create a Player from a DataSourceAdapter
 _Player*
-_Manager::createPlayer(_DataSource* source)
+_Manager::createPlayer(_DataSourceAdapter* source)
 {
-    printf("_Manager::createPlayer(_DataSource*)\n");
+    printf("_Manager::createPlayer(_DataSourceAdapter*)\n");
     if (!m_bInitialized)
     {
 	    StartEngineDriver();

Index: Umakefil
===================================================================
RCS file: /cvsroot/player/kit/jsr135/Umakefil,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Umakefil	4 Mar 2006 00:54:07 -0000	1.9
+++ Umakefil	10 Mar 2006 01:20:59 -0000	1.10
@@ -50,7 +50,7 @@
 project.AddSources(
 		'manager.cpp',
 		'player.cpp',
-		'datasource.cpp',
+		'datasourceadapter.cpp',
 		'volumecontrol.cpp',
 		'guicontrol.cpp',
 		'videocontrol.cpp',
@@ -66,7 +66,6 @@
 		'fivemmap.cpp',
 		'enginedriver.cpp',
 		'PlayerCallback.cpp',
-		'DataSourceCallback.cpp',
 		'hxsimpleringbuf.cpp',
 )
 




More information about the Player-cvs mailing list
 

Site Map   |   Terms of Use   |   Privacy Policy   |   Contact Us

Copyright © 1995-2007 RealNetworks, Inc. All rights reserved. RealNetworks and Helix are trademarks of RealNetworks.
All other trademarks or registered trademarks are the property of their respective holders.