Skip to content

Commit

Permalink
player: chromecast config - added get_service_config_type
Browse files Browse the repository at this point in the history
  • Loading branch information
juanrubio committed Nov 10, 2017
1 parent 8f77565 commit e3d71ff
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
21 changes: 19 additions & 2 deletions player/src/services/chromecast/tizchromecastconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,24 @@ namespace tiz
{
class chromecastconfig : public config
{
public:
enum service_config_type_t
{
ConfigGoogleMusic,
ConfigSoundCloud,
ConfigDirble,
ConfigYouTube,
ConfigUnknown
};

public:
chromecastconfig (const std::string &cc_name_or_ip,
const tizgraphconfig_ptr_t &service_config)
const tizgraphconfig_ptr_t &service_config,
const service_config_type_t service_config_type)
: config (service_config->get_playlist ()),
name_or_ip_ (cc_name_or_ip),
service_config_ (service_config)
service_config_ (service_config),
service_config_type_(service_config_type)
{
}

Expand All @@ -66,9 +77,15 @@ namespace tiz
return service_config_;
}

service_config_type_t get_service_config_type () const
{
return service_config_type_;
}

protected:
const std::string name_or_ip_;
tizgraphconfig_ptr_t service_config_;
service_config_type_t service_config_type_;
};
} // namespace graph
} // namespace tiz
Expand Down
28 changes: 12 additions & 16 deletions player/src/services/chromecast/tizchromecastgraphops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
#endif

namespace graph = tiz::graph;
typedef tiz::graph::chromecastconfig cc_cfg_t;

#define CC_OPS_DO_LOAD_ERROR_MSG "Unable to set a suitable component role"

//
// chromecastops
Expand All @@ -80,46 +83,40 @@ void graph::chromecastops::do_load ()
// we need.
role_lst_.clear ();

tizchromecastconfig_ptr_t cc_config_
= boost::dynamic_pointer_cast< chromecastconfig > (config_);
cc_config_ = boost::dynamic_pointer_cast< chromecastconfig > (config_);
assert (cc_config_);

const std::type_info& ti_current
= typeid (*(cc_config_->get_service_config ()));
const std::type_info& ti_gmusic = typeid (tizgmusicconfig_ptr_t);
const std::type_info& ti_scloud = typeid (tizscloudconfig_ptr_t);
const std::type_info& ti_dirble = typeid (tizdirbleconfig_ptr_t);
const std::type_info& ti_youtube = typeid (tizyoutubeconfig_ptr_t);
const cc_cfg_t::service_config_type_t config_type
= cc_config_->get_service_config_type ();

if (ti_current == ti_gmusic)
if (config_type == cc_cfg_t::ConfigGoogleMusic)
{
role_lst_.push_back ("audio_renderer.chromecast.gmusic");
config_service_func_
= boost::bind (&tiz::graph::chromecastops::do_configure_gmusic, this);
}
else if (ti_current == ti_scloud)
else if (config_type == cc_cfg_t::ConfigSoundCloud)
{
role_lst_.push_back ("audio_renderer.chromecast.scloud");
config_service_func_
= boost::bind (&tiz::graph::chromecastops::do_configure_scloud, this);
}
else if (ti_current == ti_dirble)
else if (config_type == cc_cfg_t::ConfigDirble)
{
role_lst_.push_back ("audio_renderer.chromecast.dirble");
config_service_func_
= boost::bind (&tiz::graph::chromecastops::do_configure_dirble, this);
}
else if (ti_current == ti_youtube)
else if (config_type == cc_cfg_t::ConfigYouTube)
{
role_lst_.push_back ("audio_renderer.chromecast.youtube");
config_service_func_
= boost::bind (&tiz::graph::chromecastops::do_configure_youtube, this);
}
else
{
std::string msg ("Unable to set a suitable component role");
BOOST_ASSERT_MSG (false, msg.c_str ());
G_OPS_BAIL_IF_ERROR (OMX_ErrorComponentNotFound, msg.c_str ());
BOOST_ASSERT_MSG (false, CC_OPS_DO_LOAD_ERROR_MSG);
G_OPS_BAIL_IF_ERROR (OMX_ErrorComponentNotFound, CC_OPS_DO_LOAD_ERROR_MSG);
}
// At this point we are instantiating a graph with a single component.
tiz::graph::ops::do_load ();
Expand Down Expand Up @@ -202,7 +199,6 @@ void graph::chromecastops::do_record_fatal_error (const OMX_HANDLETYPE handle,
void graph::chromecastops::do_configure_chromecast ()
{
assert (cc_config_);

G_OPS_BAIL_IF_ERROR (tiz::graph::util::set_chromecast_name_or_ip (
handles_[0], cc_config_->get_name_or_ip ()),
"Unable to set OMX_TizoniaIndexParamChromecastSession");
Expand Down
3 changes: 2 additions & 1 deletion player/src/tizplayapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,8 @@ tiz::playapp::gmusic_stream_chromecast ()

tizgraphconfig_ptr_t config
= boost::make_shared< tiz::graph::chromecastconfig > (cc_name_or_ip,
service_config);
service_config,
tiz::graph::chromecastconfig::ConfigGoogleMusic);

// Instantiate the chromecast client manager
tiz::graphmgr::mgr_ptr_t p_mgr
Expand Down

0 comments on commit e3d71ff

Please sign in to comment.