void graph::youtubeops::do_configure_comp (const int comp_id)
{
  if (last_op_succeeded ())
  {
    if (comp_id == 0)
    {
      tizyoutubeconfig_ptr_t youtube_config
          = boost::dynamic_pointer_cast< youtubeconfig > (config_);
      assert (youtube_config);

      G_OPS_BAIL_IF_ERROR (
          tiz::graph::util::set_youtube_playlist (
              handles_[0], playlist_->get_current_uri (),
              youtube_config->get_playlist_type (), playlist_->shuffle ()),
          "Unable to set OMX_TizoniaIndexParamAudioYoutubePlaylist");
    }
    else if (comp_id == 2)
    {
      G_OPS_BAIL_IF_ERROR (
          apply_default_config_on_decoder (),
          "Unable to apply the decoder's initial configuration");
    }
    else if (comp_id == 3)
    {
      G_OPS_BAIL_IF_ERROR (apply_pcm_codec_info_from_decoder (),
                           "Unable to set OMX_IndexParamAudioPcm");
    }
  }
}
void graph::httpclntops::do_load ()
{
  assert (!comp_lst_.empty ());
  assert (!role_lst_.empty ());

  // At this point we are going to instantiate the two remaining components in
  // the graph, the audio decoder and the pcm renderer. The http source is
  // already instantiated and in Executing state.

  assert (comp_lst_.size () == 1);

  dump_stream_metadata ();

  G_OPS_BAIL_IF_ERROR (
      get_encoding_type_from_http_source (),
      "Unable to retrieve the audio encoding from the http source.");

  omx_comp_name_lst_t comp_list;
  omx_comp_role_lst_t role_list;
  G_OPS_BAIL_IF_ERROR (add_decoder_to_component_list (comp_list, role_list),
                       "Unknown/unhandled stream format.");

  comp_list.push_back (tiz::graph::util::get_default_pcm_renderer ());
  role_list.push_back ("audio_renderer.pcm");

  tiz::graph::cbackhandler &cbacks = get_cback_handler ();
  G_OPS_BAIL_IF_ERROR (
      util::instantiate_comp_list (comp_list, handles_, h2n_, &(cbacks),
                                   cbacks.get_omx_cbacks ()),
      "Unable to instantiate the component list.");

  // Now add the the new components to the base class lists
  comp_lst_.insert (comp_lst_.begin (), comp_list.begin (), comp_list.end ());
  role_lst_.insert (role_lst_.begin (), role_list.begin (), role_list.end ());
}
void graph::gmusicops::do_configure_comp (const int comp_id)
{
  if (comp_id == 0)
  {
    tizgmusicconfig_ptr_t gmusic_config
        = boost::dynamic_pointer_cast< gmusicconfig > (config_);
    assert (gmusic_config);

    G_OPS_BAIL_IF_ERROR (
        tiz::graph::util::set_gmusic_user_and_device_id (
            handles_[0], gmusic_config->get_user_name (),
            gmusic_config->get_user_pass (), gmusic_config->get_device_id ()),
        "Unable to set OMX_TizoniaIndexParamAudioGmusicSession");

    G_OPS_BAIL_IF_ERROR (
        tiz::graph::util::set_gmusic_playlist (
            handles_[0], playlist_->get_current_uri (),
            gmusic_config->get_playlist_type (),
            gmusic_config->get_additional_keywords (),
            gmusic_config->is_unlimited_search (), playlist_->shuffle ()),
        "Unable to set OMX_TizoniaIndexParamAudioGmusicPlaylist");

    const OMX_U32 port_id = 0;
    G_OPS_BAIL_IF_ERROR (
        tiz::graph::util::set_streaming_buffer_params (
            handles_[0], port_id, config_->get_buffer_seconds (), 0, 100),
        "Unable to set OMX_TizoniaIndexParamStreamingBuffer");
  }
}
void graph::gmusicops::do_reconfigure_first_tunnel ()
{
  // Retrieve the mp3 settings from the gmusic source component
  OMX_AUDIO_PARAM_MP3TYPE gmusic_mp3type;
  const OMX_U32 gmusic_port_id = 0;
  TIZ_INIT_OMX_PORT_STRUCT (gmusic_mp3type, gmusic_port_id);
  G_OPS_BAIL_IF_ERROR (
      OMX_GetParameter (handles_[0], OMX_IndexParamAudioMp3, &gmusic_mp3type),
      "Unable to retrieve the MP3 settings from the gmusic source");

  // Retrieve the mp3 settings from the decoder component
  OMX_AUDIO_PARAM_MP3TYPE decoder_mp3type;
  const OMX_U32 decoder_port_id = 0;
  TIZ_INIT_OMX_PORT_STRUCT (decoder_mp3type, decoder_port_id);
  G_OPS_BAIL_IF_ERROR (
      OMX_GetParameter (handles_[1], OMX_IndexParamAudioMp3, &decoder_mp3type),
      "Unable to retrieve the MP3 settings from the audio decoder");

  // Now assign the current settings to the decoder structure
  decoder_mp3type.nChannels = gmusic_mp3type.nChannels;
  decoder_mp3type.nSampleRate = gmusic_mp3type.nSampleRate;

  // Set the new mp3 settings
  G_OPS_BAIL_IF_ERROR (
      OMX_SetParameter (handles_[1], OMX_IndexParamAudioMp3, &decoder_mp3type),
      "Unable to set the MP3 settings on the audio decoder");
}
void graph::gmusicops::do_reconfigure_second_tunnel ()
{
  // Retrieve the pcm settings from the decoder component
  OMX_AUDIO_PARAM_PCMMODETYPE decoder_pcmtype;
  const OMX_U32 decoder_port_id = 1;
  TIZ_INIT_OMX_PORT_STRUCT (decoder_pcmtype, decoder_port_id);
  G_OPS_BAIL_IF_ERROR (
      OMX_GetParameter (handles_[1], OMX_IndexParamAudioPcm, &decoder_pcmtype),
      "Unable to retrieve the PCM settings from the Mp3 decoder");

  // Retrieve the pcm settings from the renderer component
  OMX_AUDIO_PARAM_PCMMODETYPE renderer_pcmtype;
  const OMX_U32 renderer_port_id = 0;
  TIZ_INIT_OMX_PORT_STRUCT (renderer_pcmtype, renderer_port_id);
  G_OPS_BAIL_IF_ERROR (
      OMX_GetParameter (handles_[2], OMX_IndexParamAudioPcm, &renderer_pcmtype),
      "Unable to retrieve the PCM settings from the pcm renderer");

  // Now assign the current settings to the renderer structure
  renderer_pcmtype.nChannels = decoder_pcmtype.nChannels;
  renderer_pcmtype.nSamplingRate = decoder_pcmtype.nSamplingRate;

  // Set the new pcm settings
  G_OPS_BAIL_IF_ERROR (
      OMX_SetParameter (handles_[2], OMX_IndexParamAudioPcm, &renderer_pcmtype),
      "Unable to set the PCM settings on the audio renderer");

  TIZ_PRINTF_MAG (
      "     %ld Ch, %g KHz, %lu:%s:%s\n", renderer_pcmtype.nChannels,
      ((float)renderer_pcmtype.nSamplingRate) / 1000,
      renderer_pcmtype.nBitPerSample,
      renderer_pcmtype.eNumData == OMX_NumericalDataSigned ? "s" : "u",
      renderer_pcmtype.eEndian == OMX_EndianBig ? "b" : "l");
}
void graph::oggopusdecops::do_probe ()
{
  G_OPS_BAIL_IF_ERROR (
      probe_stream (OMX_PortDomainAudio, OMX_AUDIO_CodingOPUS, "OggOpus", "decode",
                    &tiz::probe::dump_pcm_info),
      "Unable to probe the stream.");
  G_OPS_BAIL_IF_ERROR (set_opus_settings (),
                       "Unable to set OMX_TizoniaIndexParamAudioOpus");
}
Exemple #7
0
void graph::vorbisdecops::do_probe ()
{
  G_OPS_BAIL_IF_ERROR (
      probe_stream (OMX_PortDomainAudio, OMX_AUDIO_CodingVORBIS, "vorbis",
                    "decode", &tiz::probe::dump_pcm_info),
      "Unable to probe the stream.");
  G_OPS_BAIL_IF_ERROR (set_vorbis_settings (),
                       "Unable to set OMX_IndexParamAudioVorbis");
}
void graph::gmusicops::do_configure ()
{
  if (last_op_succeeded ())
  {
    G_OPS_BAIL_IF_ERROR (override_decoder_and_renderer_sampling_rates (),
                         "Unable to override decoder/renderer sampling rates");
    G_OPS_BAIL_IF_ERROR (apply_pcm_codec_info_from_decoder (),
                         "Unable to set OMX_IndexParamAudioPcm");
  }
}
void graph::ops::do_setup ()
{
  if (last_op_succeeded ())
  {
    G_OPS_BAIL_IF_ERROR (util::setup_suppliers (handles_),
                         "Unable to setup suppliers.");
    G_OPS_BAIL_IF_ERROR (util::setup_tunnels (handles_),
                         "Unable to setup the tunnels.");
  }
}
Exemple #10
0
void graph::vorbisdecops::do_configure ()
{
  G_OPS_BAIL_IF_ERROR (
      tiz::graph::util::set_content_uri (handles_[0], probe_ptr_->get_uri ()),
      "Unable to set OMX_IndexParamContentURI");
  G_OPS_BAIL_IF_ERROR (
      tiz::graph::util::set_pcm_mode (
          handles_[2], 0,
          boost::bind (&tiz::probe::get_pcm_codec_info, probe_ptr_, _1)),
      "Unable to set OMX_IndexParamAudioPcm");
}
void graph::oggflacdecops::do_probe ()
{
  G_OPS_BAIL_IF_ERROR (
      probe_stream (OMX_PortDomainAudio, OMX_AUDIO_CodingFLAC, "OggFLAC",
                    "decode", &tiz::probe::dump_pcm_info),
      "Unable to probe the stream.");
  G_OPS_BAIL_IF_ERROR (
      tiz::graph::util::set_flac_type (
          handles_[1], 0,
          boost::bind (&tiz::probe::get_flac_codec_info, probe_ptr_, _1),
          need_port_settings_changed_evt_),
      "Unable to set OMX_TizoniaIndexParamAudioFlac");
}
Exemple #12
0
void graph::mp3decops::do_probe ()
{
  G_OPS_BAIL_IF_ERROR (
      probe_stream (OMX_PortDomainAudio, OMX_AUDIO_CodingMP3, "mp3", "decode",
                    &tiz::probe::dump_mp3_and_pcm_info),
      "Unable to probe the stream.");
  G_OPS_BAIL_IF_ERROR (
      tiz::graph::util::set_mp3_type (
          handles_[1], 0,
          boost::bind (&tiz::probe::get_mp3_codec_info, probe_ptr_, _1),
          need_port_settings_changed_evt_),
      "Unable to set OMX_IndexParamAudioMp3");
}
void graph::youtubeops::do_disable_comp_ports (const int comp_id,
                                               const int port_id)
{
  if (comp_id == 0)
  {
    // Disable the http source's input port
    OMX_U32 youtube_source_port = 0;
    G_OPS_BAIL_IF_ERROR (
        util::disable_port (handles_[comp_id], youtube_source_port),
        "Unable to disable youtube source's output port.");
    clear_expected_port_transitions ();
    add_expected_port_transition (handles_[comp_id], youtube_source_port,
                                  OMX_CommandPortDisable);
  }
  else if (comp_id == 1 && port_id == 0)
  {
    // Disable the demuxer's input port
    OMX_U32 demuxer_input_port = 0;
    G_OPS_BAIL_IF_ERROR (
        util::disable_port (handles_[comp_id], demuxer_input_port),
        "Unable to disable demuxer's audio port.");

    add_expected_port_transition (handles_[comp_id], demuxer_input_port,
                                  OMX_CommandPortDisable);
  }

  else if (comp_id == 1 && port_id == 1)
  {
    // Disable the demuxer's input port
    OMX_U32 demuxer_input_port = 0;
    G_OPS_BAIL_IF_ERROR (
        util::disable_port (handles_[comp_id], demuxer_input_port),
        "Unable to disable demuxer's audio port.");
    // Disable the demuxer's output ports (both of them)
    OMX_U32 demuxer_audio_port = 1;
    G_OPS_BAIL_IF_ERROR (
        util::disable_port (handles_[comp_id], demuxer_audio_port),
        "Unable to disable demuxer's audio port.");
    OMX_U32 demuxer_video_port = 2;
    G_OPS_BAIL_IF_ERROR (
        util::disable_port (handles_[comp_id], demuxer_video_port),
        "Unable to disable demuxer's video port.");
    clear_expected_port_transitions ();
    add_expected_port_transition (handles_[comp_id], demuxer_input_port,
                                  OMX_CommandPortDisable);
    add_expected_port_transition (handles_[comp_id], demuxer_audio_port,
                                  OMX_CommandPortDisable);
    add_expected_port_transition (handles_[comp_id], demuxer_video_port,
                                  OMX_CommandPortDisable);
  }
}
void graph::httpservops::do_configure_stream ()
{
  G_OPS_BAIL_IF_ERROR (
      tiz::graph::util::set_content_uri (handles_[0], probe_ptr_->get_uri ()),
      "Unable to set OMX_IndexParamContentURI");
  bool need_port_settings_changed_evt = false;  // not needed here
  G_OPS_BAIL_IF_ERROR (
      tiz::graph::util::set_mp3_type (
          handles_[1], 0,
          boost::bind (&tiz::graph::httpservops::get_mp3_codec_info, this, _1),
          need_port_settings_changed_evt),
      "Unable to set OMX_IndexParamAudioMp3");
  G_OPS_BAIL_IF_ERROR (configure_stream_metadata (),
                       "Unable to set OMX_TizoniaIndexConfigIcecastMetadata");
}
void graph::pcmdecops::do_probe ()
{
  G_OPS_BAIL_IF_ERROR (
      probe_stream (OMX_PortDomainAudio, OMX_AUDIO_CodingPCM, "pcm", "decode",
                    &tiz::probe::dump_pcm_info),
      "Unable to probe the stream.");
}
void graph::youtubeops::do_load_decoder ()
{
  assert (comp_lst_.size () == 2);
  assert (role_lst_.size () == 2);
  assert (handles_.size () == 2);

  // The audio decoder needs to be instantiated next.

  G_OPS_BAIL_IF_ERROR (
      get_encoding_type_from_container_demuxer (),
      "Unable to retrieve the audio encoding from the container demuxer.");

  omx_comp_name_lst_t comp_list;
  omx_comp_role_lst_t role_list;
  G_OPS_RECORD_IF_ERROR (add_decoder_to_component_list (comp_list, role_list),
                         "Unknown/unhandled stream format.");

  tiz::graph::cbackhandler &cbacks = get_cback_handler ();
  G_OPS_RECORD_IF_ERROR (
      util::instantiate_comp_list (comp_list, handles_, h2n_, &(cbacks),
                                   cbacks.get_omx_cbacks ()),
      "Unable to instantiate the component list.");

  // Now add the new components to the base class lists
  comp_lst_.insert (comp_lst_.begin (), comp_list.begin (), comp_list.end ());
  role_lst_.insert (role_lst_.begin (), role_list.begin (), role_list.end ());
}
void graph::gmusicops::do_configure_source ()
{
  tizgmusicconfig_ptr_t gmusic_config
      = boost::dynamic_pointer_cast< gmusicconfig >(config_);
  assert (gmusic_config);

  G_OPS_BAIL_IF_ERROR (
      set_gmusic_user_and_device_id (
          handles_[0], gmusic_config->get_user_name (),
          gmusic_config->get_user_pass (), gmusic_config->get_device_id ()),
      "Unable to set OMX_TizoniaIndexParamAudioGmusicSession");

  G_OPS_BAIL_IF_ERROR (
      set_gmusic_playlist (handles_[0], playlist_->get_current_uri ()),
      "Unable to set OMX_TizoniaIndexParamAudioGmusicPlaylist");
}
void graph::httpservops::do_probe ()
{
  G_OPS_BAIL_IF_ERROR (
      probe_stream (OMX_PortDomainAudio, OMX_AUDIO_CodingMP3, "http/mp3",
                    "server", &tiz::probe::dump_mp3_info),
      "Unable to probe the stream.");
}
void graph::ops::do_enable_auto_detection (const int handle_id, const int port_id)
{
  assert (handle_id >= 0 && static_cast<size_t>(handle_id) < handles_.size ());
  G_OPS_BAIL_IF_ERROR (
      tiz::graph::util::enable_port_format_auto_detection (
          handles_[handle_id], port_id, OMX_PortDomainAudio),
      "Unable to set OMX_IndexParamPortDefinition (port auto detection)");
}
void graph::httpclntops::do_configure ()
{
  if (last_op_succeeded ())
  {
    G_OPS_BAIL_IF_ERROR (apply_pcm_codec_info_from_http_source (),
                         "Unable to set OMX_IndexParamAudioPcm");
  }
}
void graph::ops::do_source_omx_idle2exe ()
{
  if (last_op_succeeded ())
  {
    G_OPS_BAIL_IF_ERROR (
        transition_source (OMX_StateExecuting),
        "Unable to transition source component from Idle->Exe");
  }
}
void graph::ops::do_source_omx_loaded2idle ()
{
  if (last_op_succeeded ())
  {
    G_OPS_BAIL_IF_ERROR (
        transition_source (OMX_StateIdle),
        "Unable to transition source component from Loaded->Idle");
  }
}
void graph::gmusicops::do_disable_comp_ports (const int comp_id, const int port_id)
{
  OMX_U32 gmusic_source_port = port_id;
  G_OPS_BAIL_IF_ERROR (util::disable_port (handles_[comp_id], gmusic_source_port),
                       "Unable to disable gmusic source's output port.");
  clear_expected_port_transitions ();
  add_expected_port_transition (handles_[comp_id], gmusic_source_port,
                                OMX_CommandPortDisable);
}
void graph::httpclntops::do_disable_ports ()
{
  OMX_U32 http_source_port = 0;
  G_OPS_BAIL_IF_ERROR (util::disable_port (handles_[0], http_source_port),
                       "Unable to disable http source's output port.");
  clear_expected_port_transitions ();
  add_expected_port_transition (handles_[0], http_source_port,
                                OMX_CommandPortDisable);
}
Exemple #25
0
void graph::vorbisdecops::do_disable_comp_ports (const int comp_id, const int port_id)
{
  OMX_U32 demuxers_video_port = 1;
  G_OPS_BAIL_IF_ERROR (util::disable_port (handles_[0], demuxers_video_port),
                       "Unable to disable demuxer's video port.");
  clear_expected_port_transitions ();
  add_expected_port_transition (handles_[0], demuxers_video_port,
                                OMX_CommandPortDisable);
}
void graph::ops::do_omx_idle2loaded ()
{
  if (last_op_succeeded ())
  {
    G_OPS_BAIL_IF_ERROR (
        util::transition_all (handles_, OMX_StateLoaded, OMX_StateIdle),
        "Unable to transition from Idle->Loaded");
    record_expected_transitions (OMX_StateLoaded);
  }
}
void graph::ops::do_omx_exe2idle ()
{
  if (last_op_succeeded ())
  {
    G_OPS_BAIL_IF_ERROR (
        util::transition_all (handles_, OMX_StateIdle, OMX_StateExecuting),
        "Unable to transition from Exe->Idle");
    record_expected_transitions (OMX_StateIdle);
  }
}
void graph::youtubeops::do_load_http_source ()
{
  assert (comp_lst_.size () == 0);
  assert (role_lst_.size () == 0);
  assert (handles_.size () == 0);

  // The youtube source will be instantiated now.

  omx_comp_name_lst_t comp_list;
  comp_list.push_back ("OMX.Aratelia.audio_source.http");

  omx_comp_role_lst_t role_list;
  role_list.push_back ("audio_source.http.youtube");

  G_OPS_BAIL_IF_ERROR (util::verify_comp_list (comp_list),
                       "Unable to verify the component list.");

  omx_comp_role_pos_lst_t role_positions;
  G_OPS_BAIL_IF_ERROR (
      util::verify_role_list (comp_list, role_list, role_positions),
      "Unable to verify the role list.");

  tiz::graph::cbackhandler &cbacks = get_cback_handler ();
  G_OPS_BAIL_IF_ERROR (
      util::instantiate_comp_list (comp_list, handles_, h2n_, &(cbacks),
                                   cbacks.get_omx_cbacks ()),
      "Unable to instantiate the component list.");

  G_OPS_BAIL_IF_ERROR (
      util::set_role_list (handles_, role_list, role_positions),
      "Unable to instantiate the component list.");

  // Now add the new component to the base class lists
  comp_lst_.insert (comp_lst_.begin (), comp_list.begin (), comp_list.end ());
  role_lst_.insert (role_lst_.begin (), role_list.begin (), role_list.end ());

  if (inital_graph_load_)
  {
    inital_graph_load_ = false;
    tiz::graph::util::dump_graph_info ("Youtube", "Connecting", "");
  }
}
/**
 * Default implementation of do_mute () operation. It applies mute/unmute on
 * port #0 of the last element of the graph.
 *
 */
void graph::ops::do_mute ()
{
  if (last_op_succeeded ())
  {
    OMX_U32 input_port = 0;
    assert (!handles_.empty ());
    G_OPS_BAIL_IF_ERROR (
        util::apply_mute (handles_[handles_.size () - 1], input_port),
        "Unable to apply mute");
  }
}
void graph::ops::do_omx_pause2idle ()
{
  assert (!handles_.empty ());
  if (last_op_succeeded ())
  {
    const int renderer_handle_index = handles_.size () - 1;
    G_OPS_BAIL_IF_ERROR (
        util::transition_one (handles_, renderer_handle_index, OMX_StateIdle),
        "Unable to transition renderer from Pause->Idle");
    clear_expected_transitions ();
    add_expected_transition (handles_[renderer_handle_index], OMX_StateIdle);

    for (int i = renderer_handle_index - 1; i >= 0; --i)
    {
      G_OPS_BAIL_IF_ERROR (util::transition_one (handles_, i, OMX_StateIdle),
                           "Unable to transition from Idle->Exe");
      add_expected_transition (handles_[i], OMX_StateIdle);
    }
  }
}