Esempio n. 1
0
template<class T> static bool load_nc_array(const NcFile& ncf, const string& name, vector<T>& dest, bool required = true, int offset = 0, int count = -1)
{
	NcVar *v = load_nc_variable(ncf, name.c_str(), required);
	if (v)
	{
		vector<long> offsets = list_of(offset).repeat(v->num_dims()-1, 0);
		v->set_cur(&offsets.front());
		vector<long> counts (v->num_dims());
		long* shape = v->edges();
		transform(shape, shape + v->num_dims(), offsets.begin(), counts.begin(), minus<long>());
		delete shape;
		if (count > 0)
		{
			counts[0] = count;
		}
		dest.resize(product(counts));
		bool success = v->get(&dest.front(), &counts.front());
		if (!success)
		{
			dest.resize(0);
			check(!required, string("NetcdfDataset::load_nc_array<") + typeid(T).name() + "> " + name + '\n' + "failed with offset " + str(offsets) + ", counts " + str(counts));
		}
		return success;
	}
	return false;
}
Esempio n. 2
0
namespace unary {
Point2 f1(const Point3& p, OptionalJacobian<2, 3> H) {
  return Point2();
}
double f2(const Point3& p, OptionalJacobian<1, 3> H) {
  return 0.0;
}
Vector f3(const Point3& p, OptionalJacobian<Eigen::Dynamic, 3> H) {
  return p.vector();
}
Expression<Point3> p(1);
set<Key> expected = list_of(1);
}
Esempio n. 3
0
spl::shared_ptr<core::frame_producer> create_producer(const spl::shared_ptr<core::frame_factory>& frame_factory, const core::video_format_desc& format_desc, const std::vector<std::wstring>& params)
{
	static const std::vector<std::wstring> extensions = list_of(L".png")(L".tga")(L".bmp")(L".jpg")(L".jpeg")(L".gif")(L".tiff")(L".tif")(L".jp2")(L".jpx")(L".j2k")(L".j2c");
	std::wstring filename = env::media_folder() + L"\\" + params[0];
	
	auto ext = std::find_if(extensions.begin(), extensions.end(), [&](const std::wstring& ex) -> bool
		{			
			return boost::filesystem::is_regular_file(boost::filesystem::path(filename).replace_extension(ex));
		});

	if(ext == extensions.end())
		return core::frame_producer::empty();

	return spl::make_shared<image_producer>(frame_factory, filename + *ext);
}
Esempio n. 4
0
safe_ptr<core::frame_producer> create_raw_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::vector<std::wstring>& params)
{
	static const std::vector<std::wstring> extensions = list_of(L"png")(L"tga")(L"bmp")(L"jpg")(L"jpeg")(L"gif")(L"tiff")(L"tif")(L"jp2")(L"jpx")(L"j2k")(L"j2c");
	std::wstring filename = env::media_folder() + L"\\" + params[0];
	
	auto ext = std::find_if(extensions.begin(), extensions.end(), [&](const std::wstring& ex) -> bool
		{					
			return boost::filesystem::is_regular_file(boost::filesystem::wpath(filename).replace_extension(ex));
		});

	if(ext == extensions.end())
		return core::frame_producer::empty();

	return make_safe<image_producer>(frame_factory, filename + L"." + *ext);
}
Esempio n. 5
0
void sqlite3::exec(call_context & x) {
    local_root_scope scope;

    if (x.arg.size() != 1 && x.arg.size() != 2) {
        throw exception ("SQLite3.exec() requires at least 1 argument");
    }
    
    if ( x.arg[0].is_string() ) {
        object data = create<object>();
        data.set_property("sql", x.arg[0].get_string() );        

        if ( x.arg.size() > 1 ) {
            data.set_property( "bind", x.arg[1].to_object() );
        }

        array arr(create<array>(list_of(data)));
        x.result = exec_internal( arr );
    }    
    else {
        throw exception("The first parameter of SQLite3.exec() requires to be"
                        " a string containing an SQL statement");
    }
}
namespace OpenMS
{
  const String TMTTenPlexQuantitationMethod::name_ = "tmt10plex";
  const std::vector<String> TMTTenPlexQuantitationMethod::channel_names_ = list_of("126")("127N")("127C")("128N")("128C")("129N")("129C")("130N")("130C")("131");

  TMTTenPlexQuantitationMethod::TMTTenPlexQuantitationMethod()
  {
    setName("TMTTenPlexQuantitationMethod");

    // create the channel map
    channels_.push_back(IsobaricChannelInformation("126", 0, "", 126.127725, -1, -1, 2, 3));
    channels_.push_back(IsobaricChannelInformation("127N", 1, "", 127.124760, -1, -1, 3, 4));
    channels_.push_back(IsobaricChannelInformation("127C", 2, "", 127.131079, -1, 0, 4, 5));
    channels_.push_back(IsobaricChannelInformation("128N", 3, "", 128.128114, -1, 1, 5, 6));
    channels_.push_back(IsobaricChannelInformation("128C", 4, "", 128.134433, 0, 2, 6, 7));
    channels_.push_back(IsobaricChannelInformation("129N", 5, "", 129.131468, 1, 3, 7, 8));
    channels_.push_back(IsobaricChannelInformation("129C", 6, "", 129.137787, 2, 4, 8, 9));
    channels_.push_back(IsobaricChannelInformation("130N", 7, "", 130.134822, 3, 6, 9, -1));
    channels_.push_back(IsobaricChannelInformation("130C", 8, "", 130.141141, 4, 6, -1, -1));
    channels_.push_back(IsobaricChannelInformation("131", 9, "", 131.138176, 5, 7, -1, -1));

    // we assume 126 to be the reference
    reference_channel_ = 0;

    setDefaultParams_();
  }

  TMTTenPlexQuantitationMethod::~TMTTenPlexQuantitationMethod()
  {
  }

  void TMTTenPlexQuantitationMethod::setDefaultParams_()
  {
    defaults_.setValue("channel_126_description", "", "Description for the content of the 126 channel.");
    defaults_.setValue("channel_127N_description", "", "Description for the content of the 127N channel.");
    defaults_.setValue("channel_127C_description", "", "Description for the content of the 127C channel.");
    defaults_.setValue("channel_128N_description", "", "Description for the content of the 128N channel.");
    defaults_.setValue("channel_128C_description", "", "Description for the content of the 128C channel.");
    defaults_.setValue("channel_129N_description", "", "Description for the content of the 129N channel.");
    defaults_.setValue("channel_129C_description", "", "Description for the content of the 129C channel.");
    defaults_.setValue("channel_130N_description", "", "Description for the content of the 130N channel.");
    defaults_.setValue("channel_130C_description", "", "Description for the content of the 130C channel.");
    defaults_.setValue("channel_131_description", "", "Description for the content of the 131 channel.");

    defaults_.setValue("reference_channel", "126", "The reference channel (126, 127N, 127C, 128N, 128C, 129N, 129C, 130N, 130C, 131).");
    defaults_.setValidStrings("reference_channel", TMTTenPlexQuantitationMethod::channel_names_);

    //    {0.0, 1.0, 5.9, 0.2},   //114
    //    {0.0, 2.0, 5.6, 0.1},
    //    {0.0, 3.0, 4.5, 0.1},
    //    {0.1, 4.0, 3.5, 0.1}    //117
    defaults_.setValue("correction_matrix", ListUtils::create<String>("0.0/0.0/0.0/0.0,"
                                                               "0.0/0.0/0.0/0.0,"
                                                               "0.0/0.0/0.0/0.0,"
                                                               "0.0/0.0/0.0/0.0,"
                                                               "0.0/0.0/0.0/0.0,"
                                                               "0.0/0.0/0.0/0.0,"
                                                               "0.0/0.0/0.0/0.0,"
                                                               "0.0/0.0/0.0/0.0,"
                                                               "0.0/0.0/0.0/0.0,"
                                                               "0.0/0.0/0.0/0.0"),
                       "Correction matrix for isotope distributions (see documentation); use the following format: <-2Da>/<-1Da>/<+1Da>/<+2Da>; e.g. '0/0.3/4/0', '0.1/0.3/3/0.2'");

    defaultsToParam_();
  }

  void TMTTenPlexQuantitationMethod::updateMembers_()
  {
    channels_[0].description = param_.getValue("channel_126_description");
    channels_[1].description = param_.getValue("channel_127N_description");
    channels_[2].description = param_.getValue("channel_127C_description");
    channels_[3].description = param_.getValue("channel_128N_description");
    channels_[4].description = param_.getValue("channel_128C_description");
    channels_[5].description = param_.getValue("channel_129N_description");
    channels_[6].description = param_.getValue("channel_129C_description");
    channels_[7].description = param_.getValue("channel_130N_description");
    channels_[8].description = param_.getValue("channel_130C_description");
    channels_[9].description = param_.getValue("channel_131_description");

    // compute the index of the reference channel
    std::vector<String>::const_iterator t_it = std::find(TMTTenPlexQuantitationMethod::channel_names_.begin(),
                                                         TMTTenPlexQuantitationMethod::channel_names_.end(),
                                                         (String) param_.getValue("reference_channel"));
    reference_channel_ = t_it - TMTTenPlexQuantitationMethod::channel_names_.begin();
  }

  TMTTenPlexQuantitationMethod::TMTTenPlexQuantitationMethod(const TMTTenPlexQuantitationMethod& other)
  {
    channels_.clear();
    channels_.insert(channels_.begin(), other.channels_.begin(), other.channels_.end());

    reference_channel_ = other.reference_channel_;
  }

  TMTTenPlexQuantitationMethod& TMTTenPlexQuantitationMethod::operator=(const TMTTenPlexQuantitationMethod& rhs)
  {
    if (this == &rhs)
      return *this;

    channels_.clear();
    channels_.insert(channels_.begin(), rhs.channels_.begin(), rhs.channels_.end());

    reference_channel_ = rhs.reference_channel_;

    return *this;
  }

  const String& TMTTenPlexQuantitationMethod::getName() const
  {
    return TMTTenPlexQuantitationMethod::name_;
  }

  const IsobaricQuantitationMethod::IsobaricChannelList& TMTTenPlexQuantitationMethod::getChannelInformation() const
  {
    return channels_;
  }

  Size TMTTenPlexQuantitationMethod::getNumberOfChannels() const
  {
    return 10;
  }

  Matrix<double> TMTTenPlexQuantitationMethod::getIsotopeCorrectionMatrix() const
  {
    StringList iso_correction = getParameters().getValue("correction_matrix");
    return stringListToIsotopCorrectionMatrix_(iso_correction);
  }

  Size TMTTenPlexQuantitationMethod::getReferenceChannel() const
  {
    return reference_channel_;
  }

} // namespace
Esempio n. 7
0
void
file_chooser::common_ctor_logic_()
{
  do_overwrite_confirmation_ = true;
  single_image_mode_         = false;

  if (!column) column = new model_columns;

  Glib::RefPtr< Gtk::ListStore > types;
  types = Gtk::ListStore::create (*column);
  {
    Gtk::TreeModel::Row r;
    extension_list      l;

    r = *(types->append ());
    r[column->text] = _("By extension");
    r[column->exts] = l;

    r = *(types->append ());
    r[column->text] = _("JPEG");
#if __cplusplus >= 201103L
    l = {".jpeg", ".jpg"};
#else
    l = list_of (".jpeg")(".jpg");
#endif
    r[column->exts] = l;

    r = *(types->append ());
    r[column->text] = _("PDF");
#if __cplusplus >= 201103L
    l = {".pdf"};
#else
    l = list_of (".pdf");
#endif
    r[column->exts] = l;

    r = *(types->append ());
    r[column->text] = _("PNG");
#if __cplusplus >= 201103L
    l = {".png"};
#else
    l = list_of (".png");
#endif
    r[column->exts] = l;

    r = *(types->append ());
    r[column->text] = _("PNM");
#if __cplusplus >= 201103L
    l = {".pnm"};
#else
    l = list_of (".pnm");
#endif
    r[column->exts] = l;

    r = *(types->append ());
    r[column->text] = _("TIFF");
#if __cplusplus >= 201103L
    l = {".tiff", ".tif"};
#else
    l = list_of (".tiff")(".tif");
#endif
    r[column->exts] = l;
  }

  file_type_.set_model (types);
  file_type_.set_headers_visible (false);
  file_type_.append_column ("", column->text);
  file_type_.set_rules_hint ();
  file_type_.get_selection ()->signal_changed ()
    .connect (sigc::mem_fun (*this, &file_chooser::on_file_type_changed));

  expander_.set_label (_("File Type"));
  expander_.add (file_type_);

  single_file_.set_label (_("Save all images in a single file"));
  single_file_.signal_toggled ()
    .connect (sigc::mem_fun (*this, &file_chooser::on_single_file_toggled));

  Gtk::VBox *extras (Gtk::manage (new Gtk::VBox));
  extras->pack_start (expander_);
  extras->pack_start (single_file_);

  // Set up the dialog, using layout values from Gtk::FileChooserDialog
  set_has_separator (false);
  set_border_width (5);
  get_action_area ()->set_border_width (5);

  Gtk::Box *content_area = get_vbox ();
  content_area->set_spacing (2);
  content_area->pack_start (impl_  , Gtk::PACK_EXPAND_WIDGET);
  content_area->pack_start (*extras, Gtk::PACK_SHRINK);
  content_area->show_all ();
  {
    // FIXME determine the default width and height in a way similar
    //       to how Gtk::FileChooserDialog does.  Its implementation
    //       uses an internal function which takes font information
    //       and numbers of characters and lines into account.
    //       See file_chooser_widget_default_size_changed()
    int width = 800, height = 600;
    set_default_size (width, height);
  }

  add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  add_button (Gtk::Stock::OK    , Gtk::RESPONSE_ACCEPT);

  // FIXME leave this to the "application" or tie it to file_type_
  {
    Gtk::FileFilter filter;
    filter.add_mime_type ("application/pdf");
    filter.add_mime_type ("image/*");
    filter.set_name (_("PDFs and Image Files"));
    add_filter (filter);
  }
  {
    Gtk::FileFilter filter;
    filter.add_mime_type ("image/*");
    filter.set_name (_("Image Files"));
    add_filter (filter);
  }
  {
    Gtk::FileFilter filter;
    filter.add_pattern ("*");
    filter.set_name (_("All Files"));
    add_filter (filter);
  }

  gui_name_change_dispatch_
    .connect (sigc::mem_fun (*this, &file_chooser::signal_name_change_));
  signal_name_change ()
    .connect (sigc::mem_fun (*this, &file_chooser::on_name_change_));

  cancel_watch_ = false;
  watch_thread_ = new thread (&file_chooser::watch_, this);
}
Esempio n. 8
0
 detail::mapped_generator<detail::sorter, list_generator<Gen>>
 ordered_list(const Gen& gen) {
   return map(detail::sorter(), list_of(gen));
 }
Esempio n. 9
0
 list_generator<Gen> list_of() {
   return list_of(Gen());
 }
Esempio n. 10
0
    void deps_object::test<1>()
    {
        StringDeps deps;
        StringList empty;
        // The quick brown fox jumps over the lazy yellow dog.
        // (note, "The" and "the" are distinct, else this test wouldn't work)
        deps.add("lazy");
        ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")));
        deps.add("jumps");
        ensure("found lazy", deps.get("lazy"));
        ensure("not found dog.", ! deps.get("dog."));
        // NOTE: Maybe it's overkill to test each of these intermediate
        // results before all the interdependencies have been specified. My
        // thought is simply that if the order changes, I'd like to know why.
        // A change to the implementation of boost::topological_sort() would
        // be an acceptable reason, and you can simply update the expected
        // test output.
        ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("jumps")));
        deps.add("The", 0, empty, list_of("fox")("dog."));
        // Test key accessors
        ensure("empty before deps for missing key", is_empty(deps.get_before_range("bogus")));
        ensure("empty before deps for jumps", is_empty(deps.get_before_range("jumps")));
        ensure_equals(instance_from_range< std::set<std::string> >(deps.get_before_range("The")),
                      make< std::set<std::string> >(list_of("dog.")("fox")));
        // resume building dependencies
        ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("jumps")("The")));
        deps.add("the", 0, list_of("The"));
        ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("jumps")("The")("the")));
        deps.add("fox", 0, list_of("The"), list_of("jumps"));
        ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("fox")("jumps")));
        deps.add("the", 0, list_of("The")); // same, see if cache works
        ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("fox")("jumps")));
        deps.add("jumps", 0, empty, list_of("over")); // update jumps deps
        ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("fox")("jumps")));
/*==========================================================================*|
        // It drives me nuts that this test doesn't work in the test
        // framework, because -- for reasons unknown -- running the test
        // framework on Mac OS X 10.5 Leopard and Windows XP Pro, the catch
        // clause below doesn't catch the exception. Something about the TUT
        // test framework?!? The identical code works fine in a standalone
        // test program. Commenting out the test for now, in hopes that our
        // real builds will be able to catch Cycle exceptions...
        try
        {
            // We've already specified fox -> jumps and jumps -> over. Try an
            // impossible constraint.
            deps.add("over", 0, empty, list_of("fox"));
        }
        catch (const StringDeps::Cycle& e)
        {
            std::cout << "Cycle detected: " << e.what() << '\n';
            // It's legal to add() an impossible constraint because we don't
            // detect the cycle until sort(). So sort() can't know the minimum set
            // of nodes to remove to make the StringDeps object valid again.
            // Therefore we must break the cycle by hand.
            deps.remove("over");
        }
|*==========================================================================*/
        deps.add("dog.", 0, list_of("yellow")("lazy"));
        ensure_equals(instance_from_range< std::set<std::string> >(deps.get_after_range("dog.")),
                      make< std::set<std::string> >(list_of("lazy")("yellow")));
        ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("fox")("jumps")("dog.")));
        deps.add("quick", 0, list_of("The"), list_of("fox")("brown"));
        ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("the")("quick")("fox")("jumps")("dog.")));
        deps.add("over", 0, list_of("jumps"), list_of("yellow")("the"));
        ensure_equals(sorted_keys(deps), make<StringList>(list_of("lazy")("The")("quick")("fox")("jumps")("over")("the")("dog.")));
        deps.add("yellow", 0, list_of("the"), list_of("lazy"));
        ensure_equals(sorted_keys(deps), make<StringList>(list_of("The")("quick")("fox")("jumps")("over")("the")("yellow")("lazy")("dog.")));
        deps.add("brown");
        // By now the dependencies are pretty well in place. A change to THIS
        // order should be viewed with suspicion.
        ensure_equals(sorted_keys(deps), make<StringList>(list_of("The")("quick")("brown")("fox")("jumps")("over")("the")("yellow")("lazy")("dog.")));

        StringList keys(make<StringList>(list_of("The")("brown")("dog.")("fox")("jumps")("lazy")("over")("quick")("the")("yellow")));
        ensure_equals(instance_from_range<StringList>(deps.get_key_range()), keys);
#if (! defined(__GNUC__)) || (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)
        // This is the succinct way, works on modern compilers
        ensure_equals(instance_from_range<StringList>(make_transform_range(deps.get_range(), extract_key)), keys);
#else   // gcc 3.3
        StringDeps::range got_range(deps.get_range());
        StringDeps::iterator kni = got_range.begin(), knend = got_range.end();
        StringList::iterator ki = keys.begin(), kend = keys.end();
        for ( ; kni != knend && ki != kend; ++kni, ++ki)
        {
            ensure_equals(kni->first, *ki);
        }
        ensure("get_range() returns proper length", kni == knend && ki == kend);
#endif  // gcc 3.3
        // blow off get_node_range() because they're all LLDependenciesEmpty instances
    }
Esempio n. 11
0
namespace FileSystem
{
	fs::path g_ExecPath;
	fs::path GetExecutionPath()
	{
		if(g_ExecPath.empty())
		{
			wchar_t exec_path[MAX_PATH];
			DWORD length = GetModuleFileName( NULL, exec_path, MAX_PATH );
			PathRemoveFileSpec(exec_path);

			g_ExecPath = fs::path(exec_path);
		}
		return g_ExecPath;
	}

	fs::path GetResourcesPath()
	{
		fs::path execPath = GetExecutionPath();
		std::wstring resPathStr = TEXT("/Resources");

		// check up one level
		fs::path fullPath = fs::path(execPath.parent_path().wstring() + resPathStr);
		if(fs::exists(fullPath))
			return fullPath;

		// check up two level
		fullPath = fs::path(execPath.parent_path().parent_path().wstring() + resPathStr);
		if(fs::exists(fullPath))
			return fullPath;

		// all failed
		return TEXT("");
	}

	fs::path RelativePath( const fs::path &path, const fs::path &relative_to )
	{
		// create absolute paths
		fs::path p = fs::absolute(path);
		fs::path r = fs::absolute(relative_to);

		// if root paths are different, return absolute path
		if( p.root_path() != r.root_path() )
			return p;

		// initialize relative path
		fs::path result;

		// find out where the two paths diverge
		fs::path::const_iterator itr_path = p.begin();
		fs::path::const_iterator itr_relative_to = r.begin();
		while( *itr_path == *itr_relative_to && itr_path != p.end() && itr_relative_to != r.end() ) {
			++itr_path;
			++itr_relative_to;
		}

		// add "../" for each remaining token in relative_to
		if( itr_relative_to != r.end() ) {
			++itr_relative_to;
			while( itr_relative_to != r.end() ) {
				result /= "..";
				++itr_relative_to;
			}
		}

		// add remaining path
		while( itr_path != p.end() ) {
			result /= *itr_path;
			++itr_path;
		}

		return result;
	}


	// static initializer for lookup path
	static vector<std::wstring> s_GameResourcePaths[] =
	{
		list_of( L"" ),
		list_of(L"/Shaders/")(L"/Shaders/bin/")(L"/Shaders/src/")(L"/Shaders/fx/")(L"/Scripts/"),
		list_of( L"" ),
		list_of( L"" )
	};

	fs::path CGamePath::GetResourcePath( std::wstring fnStr, eGameResourceType type )
	{
		// use type as an index, make sure it is not out of bounds
		Debug::Assert( type < CGamePath::MAX , "[error] array out of bound");

		fs::path execPath = GetResourcesPath();
		vector<std::wstring>& resPathStr = s_GameResourcePaths[type];

		fs::path fullPath;
		for( int i=0; i < (int)resPathStr.size(); ++i)
		{
			fullPath = fs::path(execPath.wstring() + resPathStr[i] + fnStr);
			if(fs::is_regular_file(fullPath))
			{
				Debug::Print((boost::wformat(TEXT("path found %s")) % fullPath.wstring()).str());
				return fullPath;
			}
		}

		Debug::Print((boost::wformat(TEXT("path not found %s")) % fullPath.wstring()).str());
		return fs::path(TEXT(""));
	}
}
Esempio n. 12
0
ApiErrorCode
StreamingSession::PlayFile(IN const string &file_name,
					 IN BOOL sync,
					 IN BOOL loop)
{

	FUNCTRACKER;

	if (_streamingSessionHandle == IW_UNDEFINED)
	{
		return API_WRONG_STATE;
	}

	// cannot sync and loop
	if (sync == TRUE && loop == TRUE && file_name != "")
	{
		LogWarn("StreamingSession::PlayFile - Cannot play sync and in loop.");
		return API_FAILURE;
	}

	_state = STREAMER_SESSION_STATE_UNKNOWN;

	IwMessagePtr response = NULL_MSG;
	int handle_index = IW_UNDEFINED;
	
	
	MsgStreamPlayReq *msg = new MsgStreamPlayReq();
	msg->streamer_handle	= _streamingSessionHandle;
	msg->file_name			= file_name;
	msg->loop				= loop;
	
	
	ApiErrorCode res = GetCurrRunningContext()->DoRequestResponseTransaction(
		_streamerHandleId,
		IwMessagePtr(msg),
		response,
		Seconds(5),
		"Plat TXN");

	if (IW_FAILURE(res) || response->message_id != MSG_STREAM_PLAY_ACK)
	{
		LogDebug("StreamingSession::PlayFile - Error sending play request to Stream, Streamh:" << _streamingSessionHandle);
		return res;
	}

	if (!sync)
	{
		return API_SUCCESS;
	}

	shared_ptr<MsgStreamPlayAck> ack = 
		dynamic_pointer_cast<MsgStreamPlayAck>(response);


	while  (true)
	{
		int handle_index = IW_UNDEFINED;
		res = GetCurrRunningContext()->WaitForTxnResponse(
			list_of(_playStoppedHandle)(_hangupHandle),
			handle_index,
			response, 
			Seconds(3600));

		if (handle_index == 1)
		{
			return API_HANGUP;
		}

		if (IW_FAILURE(res))
		{
			return res;
		}

		shared_ptr<MsgStreamPlayStopped> stopped_evt = 
			dynamic_pointer_cast<MsgStreamPlayStopped>(response);

		if (stopped_evt->correlation_id == ack->correlation_id)
		{
			_state = STREAMER_SESSION_STATE_NOT_PLAYING;
			return API_SUCCESS;
		}

	} 
}