Possible to add custom format for playback (asterisk 13)

in my lab I have a couple of plain asterisk 13.3.2 setups, it has been patched to include transcoding for the opus format, this is working fine.

My question is if it is possible to add a custom format for the Playback() application, such as a .opus file, I was hoping that would reduce cpu load as no transcoding would be needed for the playback?
Or perhaps there are other ways to do such playbacks - for an ivr or announcements use basically.

I also noticed that it doesnt seem like asterisk always picks the native format, I havent dug into this, but in a dir I have “test.ulaw test.gsm and test.wav” and for some reason, with a ulaw client/channel it chose the gsm file

any hints and clues and helpful tricks appreciated.

See the sticky article about developer questions.

uhm okay - maybe I am stupid but I couldnt find that article? please be more specific

maybe I posted in the wrong forum - but it was either here or general, I didnt think this was a developer question, I assumed it would be configurable to some degree

Looks like someone has cleaned up the sticky posts without updating the “where to post” article. There used to be an article that told you about the developer mailing lists and IRC channel.

Playback is just a front end to the standard format handling code. That uses hard coded lists of formats. I assumed you had already done development if you had added a new codec. Each format needs a piece of code that understands how to handle files in that format. That code, in the formats directory (unless they have reorganized it) registers the associated file extensions when it loads. For example, here is the code to register support for GSM in a Microsoft WAV wrapper, from the SVN trunk version:

[code]static struct ast_format_def wav49_f = {
.name = “wav49”,
.exts = “WAV|wav49”,
.open = wav_open,
.rewrite = wav_rewrite,
.write = wav_write,
.seek = wav_seek,
.trunc = wav_trunc,
.tell = wav_tell,
.read = wav_read,
.close = wav_close,
.desc_size = sizeof(struct wavg_desc),

static int load_module(void)
wav49_f.format = ast_format_gsm;
if (ast_format_def_register(&wav49_f))

This is only a small part of the complete file.

okay thank you - so i think the short answer is “no there is not a config file for such”

on the dev side - I just applied the asterisk-opus-patch by Sean Bright, I probably dont trust my 20 year old minimally used c skills to implement the file changes on my own.

so- another question relevant to this - is there any application that would be sane to use in streaming and opus file from a shellcommand or raw format directly to the rtp stream? I dont know enough about it to know if that is a sane question, heh…

The patch already adds format support:

[code]171 static struct ast_format_def vp8_f = {
172 .name = “VP8”,
173 .exts = “vp8”,
174 .open = vp8_open,
175 .write = vp8_write,
176 .seek = vp8_seek,
177 .trunc = vp8_trunc,
178 .tell = vp8_tell,
179 .read = vp8_read,
181 .desc_size = sizeof(struct vp8_desc),
182 };

184 static int load_module(void)
185 {
186 vp8_f.format = ast_format_vp8;
187 if (ast_format_def_register(&vp8_f)) {
189 }

192 } [/code]

ah yes that is for vp8 - the video format. The audio format is opus, I have no idea why there isnt a format definition for it, but only a codec.

I got the answer at irc from Sean Bright himeself - basically it is not simple and it does not exist at this point. Posting his comments here for others to find:

"the patch won't get you the ability to read the file off of disk and not transcode" "you could certainly write a format_opus. typically opus files are in ogg containers" "if i remember correctly, the problem is that the opusfile library gives you back PCM data"

So - for a developer it is possible “to write something to read the raw opus data out and send it”, but no-one has done so yet, and it takes some knowledge and effort.

I will stick to slin files for now 8)