X-Git-Url: http://code.vuplus.com/gitweb/?a=blobdiff_plain;f=xbmc%2Fcores%2Fpaplayer%2FDVDPlayerCodec.cpp;h=411d6bf15a6a8c89122c3f49965181d815507c8d;hb=fc2b1b2c1ad0d235b91a33e430d39bd63de71f58;hp=5bd7ec18c06feb9e653672bee4872cc50ed4075b;hpb=4bf98c42c189a5fcf53cba48ee00af9e7d1f2019;p=vuplus_xbmc diff --git a/xbmc/cores/paplayer/DVDPlayerCodec.cpp b/xbmc/cores/paplayer/DVDPlayerCodec.cpp index 5bd7ec1..411d6bf 100644 --- a/xbmc/cores/paplayer/DVDPlayerCodec.cpp +++ b/xbmc/cores/paplayer/DVDPlayerCodec.cpp @@ -26,6 +26,7 @@ #include "cores/dvdplayer/DVDDemuxers/DVDDemuxUtils.h" #include "cores/dvdplayer/DVDStreamInfo.h" #include "cores/dvdplayer/DVDCodecs/DVDFactoryCodec.h" +#include "music/tags/TagLoaderTagLib.h" #include "utils/log.h" #include "settings/Settings.h" #include "URL.h" @@ -77,7 +78,7 @@ bool DVDPlayerCodec::Init(const CStdString &strFile, unsigned int filecache) CURL urlFile(strFile); if (urlFile.GetProtocol() == "shout" ) - strFileToOpen.Replace("shout://","http://"); + strFileToOpen.replace(0, 8, "http://"); m_pInputStream = CDVDFactoryInputStream::CreateInputStream(NULL, strFileToOpen, m_strContentType); if (!m_pInputStream) @@ -156,6 +157,18 @@ bool DVDPlayerCodec::Init(const CStdString &strFile, unsigned int filecache) return false; } + // Extract ReplayGain info + // tagLoaderTagLib.Load will try to determine tag type by file extension, so set fallback by contentType + CStdString strFallbackFileExtension = ""; + if (m_strContentType.Equals("audio/aacp") || m_strContentType.Equals("audio/aacp" "audio/aac")) + strFallbackFileExtension = "m4a"; + else if (m_strContentType.Equals("audio/x-ms-wma")) + strFallbackFileExtension = "wma"; + else if (m_strContentType.Equals("audio/x-ape") || m_strContentType.Equals("audio/ape")) + strFallbackFileExtension = "ape"; + CTagLoaderTagLib tagLoaderTagLib; + tagLoaderTagLib.Load(strFile, m_tag, strFallbackFileExtension); + // we have to decode initial data in order to get channels/samplerate // for sanity - we read no more than 10 packets int nErrors = 0; @@ -172,7 +185,7 @@ bool DVDPlayerCodec::Init(const CStdString &strFile, unsigned int filecache) m_EncodedSampleRate = m_pAudioCodec->GetEncodedSampleRate(); m_Channels = m_pAudioCodec->GetChannels(); m_ChannelInfo = m_pAudioCodec->GetChannelMap(); - + m_BitsPerCodedSample = static_cast(pStream)->iBitsPerSample; } if (nErrors >= 10) { @@ -180,7 +193,23 @@ bool DVDPlayerCodec::Init(const CStdString &strFile, unsigned int filecache) return false; } - m_nDecodedLen = 0; + // test if seeking is supported + m_bCanSeek = false; + if (m_pInputStream->Seek(0, SEEK_POSSIBLE)) + { + // reset eof flag of stream, with eof set seek returns always success + m_pInputStream->Seek(0, SEEK_SET); + if (Seek(1) != DVD_NOPTS_VALUE) + { + // rewind stream to beginning + Seek(0); + } + else + { + m_pInputStream->Seek(0, SEEK_SET); + m_pDemuxer->Reset(); + } + } if (m_Channels == 0) // no data - just guess and hope for the best m_Channels = 2; @@ -190,6 +219,10 @@ bool DVDPlayerCodec::Init(const CStdString &strFile, unsigned int filecache) m_TotalTime = m_pDemuxer->GetStreamLength(); m_Bitrate = m_pAudioCodec->GetBitRate(); + if (!m_Bitrate && m_TotalTime) + { + m_Bitrate = (int)(((m_pInputStream->GetLength()*1000) / m_TotalTime) * 8); + } m_pDemuxer->GetStreamCodecName(m_nAudioStream,m_CodecName); m_strFileName = strFile; @@ -245,12 +278,15 @@ int64_t DVDPlayerCodec::Seek(int64_t iSeekTime) CDVDDemuxUtils::FreeDemuxPacket(m_pPacket); m_pPacket = NULL; - m_pDemuxer->SeekTime((int)iSeekTime, false); + bool ret = m_pDemuxer->SeekTime((int)iSeekTime, false); m_pAudioCodec->Reset(); m_decoded = NULL; m_nDecodedLen = 0; + if (!ret) + return DVD_NOPTS_VALUE; + return iSeekTime; } @@ -332,5 +368,5 @@ bool DVDPlayerCodec::CanInit() bool DVDPlayerCodec::CanSeek() { - return true; + return m_bCanSeek; }