# Help creating streams for unsupported types



## perrce (Feb 8, 2007)

I need the help of someone with deeper knowledge of the HME SDK than I have.

With the help of gonzotek, I found JAVE and figured out how to transcode AAC to MP3 in java. My current strategy for playing AAC files in Harmonium (at least as a proof of concept) is to create a stream for an .m4a file just as I would for an .mp3 in the application, but handle it differently in the Factory's getStream(): I would transcode to a temporary MP3 file, and then return a stream of the MP3.

When I create a stream for an .m4a file, though, I get an "unknown event opcode" , and a "handleApplicationError" message printed to the console that I can't track down. The "unknown event opcode" message is printed after createStream() is called, but before it gets to the getStream() that I overrode in the Factory.

I tracked down the origin of the "unknown event opcode" message ( Application.handleChunk() ) by searching for that string and printed a stack trace from that point. I don't know how to interpret it, though, since it occurs in a separate thread.

I can't find the source of the "handleApplicationError" message.

My best guess right now, it seems that the SDK is failing to recognize the .m4a extension and choking, even though I handle it in getStream(). I might have to modify some of TiVo's SDK code, but I don't even know what to change.

Also, the messages only print on my TiVo (Series 3). On the simulator (from the HD-HME library), it seems to run ok.

Can anyone shed some light on this?

For what it's worth, here are the messages I'm getting to the console:

```
HME SDK 1.4 (TiVo, Inc.)
LOG: added factory
MDNS: http://192.168.1.5:7288/mp3Test/
LOG: 192.168.1.2 icon.png HTTP GET - to factory /mp3Test/
DEBUG: Entering getStream()
DEBUG: File Not Found: icon.png
DEBUG: Entering application
DEBUG: Calling createStream()
LOG: HME receiver connected
LOG: unknown event opcode : 8
MP3Test[#1,uri=null] handleApplicationError(1,can't create rsrc. unsupported stream type /mp3test//home/ceperry/harmonium/test_data/music/test/test.m4a)
```
As you can see, it enters getStream() to fetch the (non-existent) icon, but never enters it again (even though it should when I call createStream() ).

Here's the stack trace that I generated at the line that prints the "unknown event opcode : 8":

```
at com.tivo.hme.sdk.Application.handleChunk(Application.java:782)
	at com.tivo.hme.host.sample.Listener.readEvents(Listener.java:306)
	at com.tivo.hme.host.sample.Listener.handleHME(Listener.java:288)
	at com.tivo.hme.host.sample.Listener.handle(Listener.java:381)
	at com.tivo.hme.host.http.server.HttpConnection.run(HttpConnection.java:123)
	at java.lang.Thread.run(Thread.java:619)
```
If your willing, you can download the test program that reproduces these symptoms. It's a zip file that contains one java file, and the JAR files that will need to be in your classpath. You can download it from: http://harmonium.dazeend.org/downloads/testing/MP3Test.zip

I know this is a big question, but I'm at a loss. Thanks.


----------



## perrce (Feb 8, 2007)

I still don't know what was going on, but for the benefit of others, I worked around the problem by transcoding before calling createStream().


----------



## perrce (Feb 8, 2007)

For the benefit of others who may search to this thread... I continued looking at the error and found the source. The application error is being sent from the receiver, so apparently the receiver is objecting to the .m4a file.


----------



## s2kdave (Jan 28, 2005)

yes, the receiver only supports certain audio types. You need to transcode it to mp3 if you want it to work. You can also set the content type to audio/mp3 on the stream.


----------



## perrce (Feb 8, 2007)

Yeah, that's what I figured out. I had to set the mime type to "audio/mpeg" since that's what's going to be sent back to the receiver after I transcode it. Now if I can just figure out how to transcode a stream. I had high hopes for JAVE. It's dead simple to use, but only goes file-to-file and I need an InputStream. Might have to directly call ffmpeg directly.


----------

