summaryrefslogtreecommitdiffstats
path: root/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxCDDA.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxCDDA.cpp')
-rw-r--r--xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxCDDA.cpp197
1 files changed, 0 insertions, 197 deletions
diff --git a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxCDDA.cpp b/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxCDDA.cpp
deleted file mode 100644
index 72067da..0000000
--- a/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxCDDA.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
1/*
2 * Copyright (C) 2013 Team XBMC
3 * http://xbmc.org
4 *
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#include "DVDInputStreams/DVDInputStream.h"
22#include "DVDDemuxCDDA.h"
23#include "DVDDemuxUtils.h"
24#include "utils/log.h"
25#include "../DVDClock.h"
26
27// CDDA audio demuxer based on AirTunes audio Demuxer.
28
29using namespace std;
30
31class CDemuxStreamAudioCDDA
32 : public CDemuxStreamAudio
33{
34public:
35 void GetStreamInfo(string& strInfo)
36 {
37 strInfo = "pcm";
38 }
39};
40
41CDVDDemuxCDDA::CDVDDemuxCDDA() : CDVDDemux()
42{
43 m_pInput = NULL;
44 m_stream = NULL;
45 m_bytes = 0;
46}
47
48CDVDDemuxCDDA::~CDVDDemuxCDDA()
49{
50 Dispose();
51}
52
53bool CDVDDemuxCDDA::Open(CDVDInputStream* pInput)
54{
55 Abort();
56
57 Dispose();
58
59 if(!pInput || !pInput->IsStreamType(DVDSTREAM_TYPE_FILE))
60 return false;
61
62 m_pInput = pInput;
63
64 m_stream = new CDemuxStreamAudioCDDA();
65
66 if(!m_stream)
67 return false;
68
69 m_stream->iSampleRate = 44100;
70 m_stream->iBitsPerSample = 16;
71 m_stream->iBitRate = 44100 * 2 * 16;
72 m_stream->iChannels = 2;
73 m_stream->type = STREAM_AUDIO;
74 m_stream->codec = AV_CODEC_ID_PCM_S16LE;
75
76 return true;
77}
78
79void CDVDDemuxCDDA::Dispose()
80{
81 delete m_stream;
82 m_stream = NULL;
83
84 m_pInput = NULL;
85 m_bytes = 0;
86}
87
88void CDVDDemuxCDDA::Reset()
89{
90 CDVDInputStream* pInputStream = m_pInput;
91 Dispose();
92 Open(pInputStream);
93}
94
95void CDVDDemuxCDDA::Abort()
96{
97 if(m_pInput)
98 return m_pInput->Abort();
99}
100
101void CDVDDemuxCDDA::Flush()
102{
103}
104
105#define CDDA_READ_SIZE 4096
106DemuxPacket* CDVDDemuxCDDA::Read()
107{
108 if(!m_pInput)
109 return NULL;
110
111 DemuxPacket* pPacket = CDVDDemuxUtils::AllocateDemuxPacket(CDDA_READ_SIZE);
112
113 if (!pPacket)
114 {
115 if (m_pInput)
116 m_pInput->Close();
117 return NULL;
118 }
119
120 pPacket->iSize = m_pInput->Read(pPacket->pData, CDDA_READ_SIZE);
121 pPacket->iStreamId = 0;
122
123 if(pPacket->iSize < 1)
124 {
125 delete pPacket;
126 pPacket = NULL;
127 }
128 else
129 {
130 int n = m_stream->iBitRate>>3;
131 if (n > 0)
132 {
133 m_bytes += pPacket->iSize;
134 pPacket->dts = (double)m_bytes * DVD_TIME_BASE / n;
135 pPacket->pts = pPacket->dts;
136 }
137 else
138 {
139 pPacket->dts = DVD_NOPTS_VALUE;
140 pPacket->pts = DVD_NOPTS_VALUE;
141 }
142 }
143
144 return pPacket;
145}
146
147bool CDVDDemuxCDDA::SeekTime(int time, bool backwords, double* startpts)
148{
149 int bytes_per_second = m_stream->iBitRate>>3;
150 // clamp seeks to bytes per full sample
151 int clamp_bytes = (m_stream->iBitsPerSample>>3) * m_stream->iChannels;
152
153 // time is in milliseconds
154 int64_t seekPos = m_pInput->Seek((((int64_t)time * bytes_per_second / 1000) / clamp_bytes ) * clamp_bytes, SEEK_SET) > 0;
155 if (seekPos > 0)
156 m_bytes = seekPos;
157
158 if (startpts)
159 *startpts = (double)m_bytes * DVD_TIME_BASE / bytes_per_second;
160
161 return seekPos > 0;
162};
163
164int CDVDDemuxCDDA::GetStreamLength()
165{
166 int64_t num_track_bytes = m_pInput->GetLength();
167 int bytes_per_second = (m_stream->iBitRate>>3);
168 int64_t track_mseconds = num_track_bytes*1000 / bytes_per_second;
169 return (int)track_mseconds;
170}
171
172CDemuxStream* CDVDDemuxCDDA::GetStream(int iStreamId)
173{
174 if(iStreamId != 0)
175 return NULL;
176
177 return m_stream;
178}
179
180int CDVDDemuxCDDA::GetNrOfStreams()
181{
182 return (m_stream == NULL ? 0 : 1);
183}
184
185std::string CDVDDemuxCDDA::GetFileName()
186{
187 if(m_pInput)
188 return m_pInput->GetFileName();
189 else
190 return "";
191}
192
193void CDVDDemuxCDDA::GetStreamCodecName(int iStreamId, std::string &strName)
194{
195 if (m_stream && iStreamId == 0)
196 strName = "pcm";
197}