Skip to content

Commit

Permalink
Add exception support for Sony Blu-ray Players for UPNP
Browse files Browse the repository at this point in the history
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 117b1b0
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 20 deletions.
56 changes: 37 additions & 19 deletions mythtv/libs/libmythupnp/upnpcds.cpp
Expand Up @@ -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)
{
Expand All @@ -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));

}


Expand Down
4 changes: 3 additions & 1 deletion mythtv/libs/libmythupnp/upnpcds.h
Expand Up @@ -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;

//////////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 8 additions & 0 deletions mythtv/programs/mythbackend/upnpcdstv.cpp
Expand Up @@ -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 )
Expand Down
8 changes: 8 additions & 0 deletions mythtv/programs/mythbackend/upnpcdsvideo.cpp
Expand Up @@ -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 );
Expand Down

0 comments on commit 117b1b0

Please sign in to comment.