Search code examples
icecastoggshoutcastopusicecast2

Streaming opus to icecast server using libshout


I'm trying to send Opus encoded data to icecast server using libshout. I record PCM data on Android encode it to Opus and send to icecast using libshout like this:

  1. Encoding:
opus_encoder_create(SAMPLE_RATE == 8000, 1, OPUS_APPLICATION_VOIP, &error);
opus_encode(encoder.get(), &pcm[0], FRAME_SIZE == 640, data, MAX_PACKET_SIZE == 1276);
  1. Sending
shout_set_host(_shout.get(), "10.0.2.2");
shout_set_protocol(_shout.get(), SHOUT_PROTOCOL_HTTP);
shout_set_port(_shout.get(), 8000);
shout_set_password(_shout.get(), "hackme");
shout_set_mount(_shout.get(), "/example.opus");
shout_set_user(_shout.get(), "source");
shout_set_content_format(_shout.get(), SHOUT_FORMAT_VORBIS, SHOUT_USAGE_AUDIO, nullptr);
shout_set_description(_shout.get(), "TEST STREAM");
shout_set_tls(_shout.get(), SHOUT_TLS_DISABLED);
shout_set_audio_info(_shout.get(), SHOUT_AI_CHANNELS, "1");
shout_set_audio_info(_shout.get(), SHOUT_AI_SAMPLERATE, "8000");
shout_open(_shout.get());
shout_send_raw(_shout.get(), data, len);

I can see that shout_send_raw returns number of bytes sent and I can see my stream in icecast web interface but when I hit play nothing happens. I also see that total_bytes_read in web interface is increasing but total_bytes_sent stays 0. When I tried to use shout_send however it just returns 0 and casting stops. What am I doing wrong here? Should I somehow point out to libshout that I'm sending opus encoded data?


Solution

  • The solution was to basically pack opus stream into ogg container. I used libopusenc for this.