Skip to content

Commit b36bcb7

Browse files
committed
HTSP Video: Add some mostly non-working entries for additional audio formats
1 parent 67f9cd8 commit b36bcb7

File tree

4 files changed

+89
-11
lines changed

4 files changed

+89
-11
lines changed

app/src/main/java/ie/macinnes/tvheadend/Constants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
import android.media.tv.TvContract;
1919

2020
public class Constants {
21+
// Use sparingly, i.e. for wrapping log messages that would otherwise spam during normal
22+
// operation. Even Log.v/Log.v logs will slow things down if called enough.
23+
public static final boolean DEBUG = false;
2124

2225
// Misc Things
2326
public static final String CONTENT_AUTHORITY = TvContract.AUTHORITY;

app/src/main/java/ie/macinnes/tvheadend/player/HtspDataSource.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import ie.macinnes.htsp.HtspMessage;
3636
import ie.macinnes.htsp.SimpleHtspConnection;
3737
import ie.macinnes.htsp.tasks.Subscriber;
38+
import ie.macinnes.tvheadend.Constants;
3839

3940
public class HtspDataSource implements DataSource, Subscriber.Listener {
4041
private static final String TAG = HtspDataSource.class.getName();
@@ -103,7 +104,8 @@ public int read(byte[] buffer, int offset, int readLength) throws IOException {
103104
// If the buffer is empty, block until we have at least 1 byte
104105
while (mIsOpen && mBuffer.remaining() == 0) {
105106
try {
106-
Log.v(TAG, "Blocking for more data");
107+
if (Constants.DEBUG)
108+
Log.v(TAG, "Blocking for more data");
107109
Thread.sleep(250);
108110
} catch (InterruptedException e) {
109111
// Ignore.

app/src/main/java/ie/macinnes/tvheadend/player/HtspExtractor.java

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.nio.ByteBuffer;
4040

4141
import ie.macinnes.htsp.HtspMessage;
42+
import ie.macinnes.tvheadend.Constants;
4243
import ie.macinnes.tvheadend.TvhMappings;
4344

4445

@@ -101,7 +102,8 @@ public int read(ExtractorInput input, PositionHolder seekPosition) throws IOExce
101102

102103
int bytesRead = input.read(rawBytes, 0, rawBytes.length);
103104

104-
Log.v(TAG, "Read " + bytesRead + " bytes");
105+
if (Constants.DEBUG)
106+
Log.v(TAG, "Read " + bytesRead + " bytes");
105107

106108
ByteArrayInputStream inputStream = new ByteArrayInputStream(rawBytes, 0, bytesRead);
107109
ObjectInput objectInput = null;
@@ -142,6 +144,8 @@ public void release() {
142144

143145
}
144146

147+
148+
145149
// Internal Methods
146150
private void handleMessage(@NonNull final HtspMessage message) {
147151
final String method = message.getString("method");
@@ -223,7 +227,28 @@ private void handleSubscriptionStart(@NonNull final HtspMessage message) {
223227
C.ENCODING_PCM_16BIT,
224228
null,
225229
null,
226-
0,
230+
C.SELECTION_FLAG_AUTOSELECT,
231+
stream.getString("language", "und")
232+
);
233+
break;
234+
case "EAC3":
235+
rate = Format.NO_VALUE;
236+
if (stream.containsKey("rate")) {
237+
rate = TvhMappings.sriToRate(stream.getInteger("rate"));
238+
}
239+
240+
format = Format.createAudioSampleFormat(
241+
Integer.toString(streamIndex),
242+
MimeTypes.AUDIO_E_AC3,
243+
null,
244+
Format.NO_VALUE,
245+
Format.NO_VALUE,
246+
stream.getInteger("channels", Format.NO_VALUE),
247+
rate,
248+
C.ENCODING_PCM_16BIT,
249+
null,
250+
null,
251+
C.SELECTION_FLAG_AUTOSELECT,
227252
stream.getString("language", "und")
228253
);
229254
break;
@@ -235,7 +260,7 @@ private void handleSubscriptionStart(@NonNull final HtspMessage message) {
235260

236261
format = Format.createAudioSampleFormat(
237262
Integer.toString(streamIndex),
238-
MimeTypes.AUDIO_MPEG,
263+
MimeTypes.AUDIO_MPEG_L2,
239264
null,
240265
Format.NO_VALUE,
241266
Format.NO_VALUE,
@@ -244,7 +269,49 @@ private void handleSubscriptionStart(@NonNull final HtspMessage message) {
244269
C.ENCODING_PCM_16BIT,
245270
null,
246271
null,
247-
0,
272+
C.SELECTION_FLAG_AUTOSELECT,
273+
stream.getString("language", "und")
274+
);
275+
break;
276+
case "VORBIS":
277+
rate = Format.NO_VALUE;
278+
if (stream.containsKey("rate")) {
279+
rate = TvhMappings.sriToRate(stream.getInteger("rate"));
280+
}
281+
282+
format = Format.createAudioSampleFormat(
283+
Integer.toString(streamIndex),
284+
MimeTypes.AUDIO_VORBIS,
285+
null,
286+
Format.NO_VALUE,
287+
Format.NO_VALUE,
288+
stream.getInteger("channels", Format.NO_VALUE),
289+
rate,
290+
Format.NO_VALUE,
291+
null,
292+
null,
293+
C.SELECTION_FLAG_AUTOSELECT,
294+
stream.getString("language", "und")
295+
);
296+
break;
297+
case "AAC":
298+
rate = Format.NO_VALUE;
299+
if (stream.containsKey("rate")) {
300+
rate = TvhMappings.sriToRate(stream.getInteger("rate"));
301+
}
302+
303+
format = Format.createAudioSampleFormat(
304+
Integer.toString(streamIndex),
305+
MimeTypes.AUDIO_AAC,
306+
null,
307+
Format.NO_VALUE,
308+
Format.NO_VALUE,
309+
stream.getInteger("channels", Format.NO_VALUE),
310+
rate,
311+
Format.NO_VALUE,
312+
null,
313+
null,
314+
C.SELECTION_FLAG_AUTOSELECT,
248315
stream.getString("language", "und")
249316
);
250317
break;

app/src/main/java/ie/macinnes/tvheadend/sync/EpgSyncTask.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ private void handleChannelAddUpdate(@NonNull HtspMessage message) {
245245

246246
if (channelUri == null) {
247247
// Insert the channel
248-
Log.v(TAG, "Insert channel " + channelId);
248+
if (Constants.DEBUG)
249+
Log.v(TAG, "Insert channel " + channelId);
249250
mPendingChannelOps.put(
250251
channelId,
251252
ContentProviderOperation.newInsert(TvContract.Channels.CONTENT_URI)
@@ -254,7 +255,8 @@ private void handleChannelAddUpdate(@NonNull HtspMessage message) {
254255
);
255256
} else {
256257
// Update the channel
257-
Log.v(TAG, "Update channel " + channelId);
258+
if (Constants.DEBUG)
259+
Log.v(TAG, "Update channel " + channelId);
258260
mPendingChannelOps.put(
259261
channelId,
260262
ContentProviderOperation.newUpdate(channelUri)
@@ -332,7 +334,8 @@ protected void deleteChannels() {
332334

333335
for (int i = 0; i < existingChannelIds.length; i++) {
334336
if (!mSeenChannels.contains(existingChannelIds[i])) {
335-
Log.d(TAG, "Deleting channel " + existingChannelIds[i]);
337+
if (Constants.DEBUG)
338+
Log.d(TAG, "Deleting channel " + existingChannelIds[i]);
336339
Uri channelUri = mChannelUriMap.get(existingChannelIds[i]);
337340
mChannelUriMap.remove(existingChannelIds[i]);
338341
mContentResolver.delete(channelUri, null, null);
@@ -432,7 +435,8 @@ private void handleEventAddUpdate(@NonNull HtspMessage message) {
432435

433436
if (eventUri == null) {
434437
// Insert the event
435-
Log.v(TAG, "Insert event " + eventId + " on channel " + channelId);
438+
if (Constants.DEBUG)
439+
Log.v(TAG, "Insert event " + eventId + " on channel " + channelId);
436440
mPendingProgramOps.put(
437441
eventId,
438442
ContentProviderOperation.newInsert(TvContract.Programs.CONTENT_URI)
@@ -441,7 +445,8 @@ private void handleEventAddUpdate(@NonNull HtspMessage message) {
441445
);
442446
} else {
443447
// Update the event
444-
Log.v(TAG, "Update event " + eventId + " on channel " + channelId);
448+
if (Constants.DEBUG)
449+
Log.v(TAG, "Update event " + eventId + " on channel " + channelId);
445450
mPendingProgramOps.put(
446451
eventId,
447452
ContentProviderOperation.newUpdate(eventUri)
@@ -515,7 +520,8 @@ protected void deletePrograms() {
515520

516521
for (int i = 0; i < existingProgramIds.length; i++) {
517522
if (!mSeenPrograms.contains(existingProgramIds[i])) {
518-
Log.d(TAG, "Deleting program " + existingProgramIds[i]);
523+
if (Constants.DEBUG)
524+
Log.d(TAG, "Deleting program " + existingProgramIds[i]);
519525
Uri programUri = mProgramUriMap.get(existingProgramIds[i]);
520526
mProgramUriMap.remove(existingProgramIds[i]);
521527
mContentResolver.delete(programUri, null, null);

0 commit comments

Comments
 (0)