Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OMXPlayer use DVDFactoryDemuxer for every media. With new CDDA demuxer RPi xbmc plays audio CDs.
- Loading branch information
Showing
6 changed files
with
265 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
/* | ||
* Copyright (C) 2013 Team XBMC | ||
* http://www.xbmc.org | ||
* | ||
* This Program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This Program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with XBMC; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include "DVDInputStreams/DVDInputStream.h" | ||
#include "DVDDemuxCDDA.h" | ||
#include "DVDDemuxUtils.h" | ||
#include "utils/log.h" | ||
#include "../DVDClock.h" | ||
|
||
// CDDA audio demuxer based on AirTunes audio Demuxer. | ||
|
||
using namespace std; | ||
|
||
class CDemuxStreamAudioCDDA | ||
: public CDemuxStreamAudio | ||
{ | ||
public: | ||
void GetStreamInfo(string& strInfo) | ||
{ | ||
strInfo = "pcm"; | ||
} | ||
}; | ||
|
||
CDVDDemuxCDDA::CDVDDemuxCDDA() : CDVDDemux() | ||
{ | ||
m_pInput = NULL; | ||
m_stream = NULL; | ||
m_bytes = 0; | ||
} | ||
|
||
CDVDDemuxCDDA::~CDVDDemuxCDDA() | ||
{ | ||
Dispose(); | ||
} | ||
|
||
bool CDVDDemuxCDDA::Open(CDVDInputStream* pInput) | ||
{ | ||
Abort(); | ||
|
||
Dispose(); | ||
|
||
if(!pInput || !pInput->IsStreamType(DVDSTREAM_TYPE_FILE)) | ||
return false; | ||
|
||
m_pInput = pInput; | ||
|
||
m_stream = new CDemuxStreamAudioCDDA(); | ||
|
||
if(!m_stream) | ||
return false; | ||
|
||
m_stream->iSampleRate = 44100; | ||
m_stream->iBitsPerSample = 16; | ||
m_stream->iBitRate = 44100 * 2 * 16; | ||
m_stream->iChannels = 2; | ||
m_stream->type = STREAM_AUDIO; | ||
m_stream->codec = CODEC_ID_PCM_S16LE; | ||
|
||
return true; | ||
} | ||
|
||
void CDVDDemuxCDDA::Dispose() | ||
{ | ||
delete m_stream; | ||
m_stream = NULL; | ||
|
||
m_pInput = NULL; | ||
m_bytes = 0; | ||
} | ||
|
||
void CDVDDemuxCDDA::Reset() | ||
{ | ||
CDVDInputStream* pInputStream = m_pInput; | ||
Dispose(); | ||
Open(pInputStream); | ||
} | ||
|
||
void CDVDDemuxCDDA::Abort() | ||
{ | ||
if(m_pInput) | ||
return m_pInput->Abort(); | ||
} | ||
|
||
void CDVDDemuxCDDA::Flush() | ||
{ | ||
} | ||
|
||
#define CDDA_READ_SIZE 4096 | ||
DemuxPacket* CDVDDemuxCDDA::Read() | ||
{ | ||
if(!m_pInput) | ||
return NULL; | ||
|
||
DemuxPacket* pPacket = CDVDDemuxUtils::AllocateDemuxPacket(CDDA_READ_SIZE); | ||
|
||
if (!pPacket) | ||
{ | ||
if (m_pInput) | ||
m_pInput->Close(); | ||
return NULL; | ||
} | ||
|
||
pPacket->iSize = m_pInput->Read(pPacket->pData, CDDA_READ_SIZE); | ||
pPacket->iStreamId = 0; | ||
|
||
if(pPacket->iSize < 1) | ||
{ | ||
delete pPacket; | ||
pPacket = NULL; | ||
} | ||
else | ||
{ | ||
int n = m_stream->iBitRate>>3; | ||
if (n > 0) | ||
{ | ||
m_bytes += pPacket->iSize; | ||
pPacket->dts = (double)m_bytes * DVD_TIME_BASE / n; | ||
pPacket->pts = pPacket->dts; | ||
} | ||
else | ||
{ | ||
pPacket->dts = DVD_NOPTS_VALUE; | ||
pPacket->pts = DVD_NOPTS_VALUE; | ||
} | ||
} | ||
|
||
return pPacket; | ||
} | ||
|
||
int CDVDDemuxCDDA::GetStreamLength() | ||
{ | ||
int64_t num_track_bytes = m_pInput->GetLength(); | ||
int bytes_per_second = (m_stream->iBitRate>>3); | ||
int64_t track_mseconds = num_track_bytes*1000 / bytes_per_second; | ||
return (int)track_mseconds; | ||
} | ||
|
||
CDemuxStream* CDVDDemuxCDDA::GetStream(int iStreamId) | ||
{ | ||
if(iStreamId != 0) | ||
return NULL; | ||
|
||
return m_stream; | ||
} | ||
|
||
int CDVDDemuxCDDA::GetNrOfStreams() | ||
{ | ||
return (m_stream == NULL ? 0 : 1); | ||
} | ||
|
||
std::string CDVDDemuxCDDA::GetFileName() | ||
{ | ||
if(m_pInput) | ||
return m_pInput->GetFileName(); | ||
else | ||
return ""; | ||
} | ||
|
||
void CDVDDemuxCDDA::GetStreamCodecName(int iStreamId, CStdString &strName) | ||
{ | ||
if (m_stream && iStreamId == 0) | ||
strName = "pcm"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#pragma once | ||
/* | ||
* Copyright (C) 2013 Team XBMC | ||
* http://www.xbmc.org | ||
* | ||
* This Program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2, or (at your option) | ||
* any later version. | ||
* | ||
* This Program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with XBMC; see the file COPYING. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include "DVDDemux.h" | ||
|
||
#ifdef _WIN32 | ||
#define __attribute__(dummy_val) | ||
#else | ||
#include <config.h> | ||
#endif | ||
|
||
class CDemuxStreamAudioCDDA; | ||
|
||
class CDVDDemuxCDDA : public CDVDDemux | ||
{ | ||
public: | ||
|
||
CDVDDemuxCDDA(); | ||
~CDVDDemuxCDDA(); | ||
|
||
bool Open(CDVDInputStream* pInput); | ||
void Dispose(); | ||
void Reset(); | ||
void Abort(); | ||
void Flush(); | ||
DemuxPacket* Read(); | ||
bool SeekTime(int time, bool backwords = false, double* startpts = NULL) { return false; }; | ||
void SetSpeed(int iSpeed) {}; | ||
int GetStreamLength() ; | ||
CDemuxStream* GetStream(int iStreamId); | ||
int GetNrOfStreams(); | ||
std::string GetFileName(); | ||
virtual void GetStreamCodecName(int iStreamId, CStdString &strName); | ||
|
||
protected: | ||
friend class CDemuxStreamAudioCDDA; | ||
CDVDInputStream* m_pInput; | ||
int64_t m_bytes; | ||
|
||
CDemuxStreamAudioCDDA *m_stream; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters