Skip to content
Permalink
Browse files

Add exception support for Sony Blu-ray Players for UPNP

Fixes #9424

Patch from the ticket, slightly massaged and cleaned up.  Seems that Sony
Blu-ray players want the mime type to be video/avi for some silly reason.

Signed-off-by: Gavin Hurlbut <ghurlbut@mythtv.org>
  • Loading branch information
matt123p authored and Beirdo committed Jul 25, 2011
1 parent 3520eff commit 117b1b0fd3a03762cfa59c3c44ca3cc6a56f134d
@@ -215,38 +215,58 @@ bool UPnpCDS::ProcessRequest( HttpWorkerThread *pThread, HTTPRequest *pRequest )

static UPnpCDSClientException clientExceptions[] = {
// Windows Media Player version 12
{ CDS_ClientWMP, "Windows-Media-Player" },
{ CDS_ClientWMP,
"User-Agent",
"Windows-Media-Player/" },
// Windows Media Player version < 12
{ CDS_ClientWMP, "Mozilla/4.0 (compatible; UPnP/1.0; Windows 9x" },
{ CDS_ClientWMP,
"User-Agent",
"Mozilla/4.0 (compatible; UPnP/1.0; Windows 9x" },
// XBMC
{ CDS_ClientXBMC, "Platinum" },
{ CDS_ClientXBMC,
"User-Agent",
"Platinum/" },
// XBox 360
{ CDS_ClientXBox, "Xbox" },
{ CDS_ClientXBox,
"User-Agent",
"Xbox" },
// Sony Blu-ray players
{ CDS_ClientSonyDB,
"X-AV-Client-Info",
"cn=\"Sony Corporation\"; mn=\"Blu-ray Disc Player\"" },
};
static uint clientExceptionCount = sizeof(clientExceptions) /
sizeof(clientExceptions[0]);

void UPnpCDS::DetermineClient( HTTPRequest *pRequest,
UPnpCDSRequest *pCDSRequest )
{
QString sUserAgent = pRequest->GetHeaderValue( "User-Agent", "" );

pCDSRequest->m_eClient = CDS_ClientDefault;
pCDSRequest->m_nClientVersion = 0;
bool found = false;

// Do we know this client string?
for ( uint i = 0; i < clientExceptionCount; i++ )
for ( uint i = 0; !found && i < clientExceptionCount; i++ )
{
UPnpCDSClientException *except = &clientExceptions[i];

int idx = sUserAgent.indexOf(except->sClientId);
QString sHeaderValue = pRequest->GetHeaderValue(except->sHeaderKey, "");
int idx = sHeaderValue.indexOf(except->sHeaderValue);
if (idx != -1)
{
pCDSRequest->m_eClient = except->nClientType;;
pCDSRequest->m_eClient = except->nClientType;

idx += except->sHeaderValue.length();

// If we have a / at the end of the string then we
// increment the string to skip over it
if ( sHeaderValue[idx] == '/')
{
idx++;
}

// Now find the version number
QString version =
sUserAgent.mid( idx + except->sClientId.length() + 1 ).trimmed();
QString version = sHeaderValue.mid(idx).trimmed();
idx = version.indexOf( '.' );
if (idx != -1)
{
@@ -264,16 +284,14 @@ void UPnpCDS::DetermineClient( HTTPRequest *pRequest,

pCDSRequest->m_nClientVersion = version.toDouble();

break;
LOG(VB_UPNP, LOG_INFO,
QString("DetermineClient %1:%2 Identified as %3 version %4")
.arg(except->sHeaderKey) .arg(sHeaderValue)
.arg(pCDSRequest->m_eClient)
.arg(pCDSRequest->m_nClientVersion));
found = true;
}
}

LOG(VB_UPNP, LOG_INFO,
QString("UPnpCDS::DetermineClient User-Agent:%1 Indentified as "
"%2 version %3")
.arg(sUserAgent) .arg(pCDSRequest->m_eClient)
.arg(pCDSRequest->m_nClientVersion));

}


@@ -62,12 +62,14 @@ typedef enum
CDS_ClientXBMC = 2, // XBMC
CDS_ClientMP101 = 3, // Netgear MP101
CDS_ClientXBox = 4, // XBox 360
CDS_ClientSonyDB = 5, // Sony Blu-ray players
} UPnpCDSClient;

typedef struct
{
UPnpCDSClient nClientType;
QString sClientId;
QString sHeaderKey;
QString sHeaderValue;
} UPnpCDSClientException;

//////////////////////////////////////////////////////////////////////////////
@@ -391,6 +391,14 @@ void UPnpCDSTv::AddItem( const UPnpCDSRequest *pRequest,
sMimeType = "video/x-ms-dvr";
}

// If we are dealing with a Sony Blu-ray player then we fake the
// MIME type to force the video to appear
if ( pRequest->m_eClient == CDS_ClientSonyDB )
{
sMimeType = "video/avi";
}


// DLNA string below is temp fix for ps3 seeking.
QString sProtocol = QString( "http-get:*:%1:DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01500000000000000000000000000000" ).arg( sMimeType );
QString sURI = QString( "%1GetRecording%2").arg( sURIBase )
@@ -365,6 +365,14 @@ void UPnpCDSVideo::AddItem( const UPnpCDSRequest *pRequest,
// ----------------------------------------------------------------------

QString sMimeType = HTTPRequest::GetMimeType( fInfo.suffix() );

// If we are dealing with a Sony Blu-ray player then we fake the
// MIME type to force the video to appear
if ( pRequest->m_eClient == CDS_ClientSonyDB )
{
sMimeType = "video/avi";
}

QString sProtocol = QString( "http-get:*:%1:DLNA.ORG_OP=01;DLNA.ORG_CI=0;"
"DLNA.ORG_FLAGS=0150000000000000000000000000"
"0000" ).arg( sMimeType );

0 comments on commit 117b1b0

Please sign in to comment.
You can’t perform that action at this time.