#include "AudioCapture_impl.h" #include "AudioCaptureFactory.h" #include "api_generator/wp8/MethodResultImpl.h" using namespace rho::apiGenerator; using namespace rhoruntime; namespace rho { void CAudioCaptureImpl::getSource(CMethodResult& oResult) { try { _runtime->getSource(ref new CMethodResultImpl((int64)&oResult)); } catch (Platform::Exception^ e) { LOG(ERROR) + rho::common::convertStringAFromWP8(e->ToString()); } } void CAudioCaptureImpl::setSource(const rho::String& source, CMethodResult& oResult) { Platform::String^ _source = rho::common::convertStringToWP8(source); try { _runtime->setSource(_source, ref new CMethodResultImpl((int64)&oResult)); } catch (Platform::Exception^ e) { LOG(ERROR) + rho::common::convertStringAFromWP8(e->ToString()); } } void CAudioCaptureImpl::getEncoder(CMethodResult& oResult) { try { _runtime->getEncoder(ref new CMethodResultImpl((int64)&oResult)); } catch (Platform::Exception^ e) { LOG(ERROR) + rho::common::convertStringAFromWP8(e->ToString()); } } void CAudioCaptureImpl::setEncoder(const rho::String& encoder, CMethodResult& oResult) { Platform::String^ _encoder = rho::common::convertStringToWP8(encoder); try { _runtime->setEncoder(_encoder, ref new CMethodResultImpl((int64)&oResult)); } catch (Platform::Exception^ e) { LOG(ERROR) + rho::common::convertStringAFromWP8(e->ToString()); } } void CAudioCaptureImpl::getMaxDuration(CMethodResult& oResult) { try { _runtime->getMaxDuration(ref new CMethodResultImpl((int64)&oResult)); } catch (Platform::Exception^ e) { LOG(ERROR) + rho::common::convertStringAFromWP8(e->ToString()); } } void CAudioCaptureImpl::setMaxDuration(int maxDuration, CMethodResult& oResult) { try { _runtime->setMaxDuration(maxDuration, ref new CMethodResultImpl((int64)&oResult)); } catch (Platform::Exception^ e) { LOG(ERROR) + rho::common::convertStringAFromWP8(e->ToString()); } } void CAudioCaptureImpl::getFileName(CMethodResult& oResult) { try { _runtime->getFileName(ref new CMethodResultImpl((int64)&oResult)); } catch (Platform::Exception^ e) { LOG(ERROR) + rho::common::convertStringAFromWP8(e->ToString()); } } void CAudioCaptureImpl::setFileName(const rho::String& fileName, CMethodResult& oResult) { Platform::String^ _fileName = rho::common::convertStringToWP8(fileName); try { _runtime->setFileName(_fileName, ref new CMethodResultImpl((int64)&oResult)); } catch (Platform::Exception^ e) { LOG(ERROR) + rho::common::convertStringAFromWP8(e->ToString()); } } void CAudioCaptureImpl::start(const rho::Hashtable& props, CMethodResult& oResult) { Windows::Foundation::Collections::IMapView^ _props = rho::common::convertHashToWP8(props); try { _runtime->start(_props, ref new CMethodResultImpl((int64)&oResult)); } catch (Platform::Exception^ e) { LOG(ERROR) + rho::common::convertStringAFromWP8(e->ToString()); } } void CAudioCaptureImpl::stop(CMethodResult& oResult) { try { _runtime->stop(ref new CMethodResultImpl((int64)&oResult)); } catch (Platform::Exception^ e) { LOG(ERROR) + rho::common::convertStringAFromWP8(e->ToString()); } } void CAudioCaptureImpl::cancel(CMethodResult& oResult) { try { _runtime->cancel(ref new CMethodResultImpl((int64)&oResult)); } catch (Platform::Exception^ e) { LOG(ERROR) + rho::common::convertStringAFromWP8(e->ToString()); } } class CAudioCaptureSingleton: public CAudioCaptureSingletonBase { private: IAudioCaptureSingletonImpl^ _runtime; public: CAudioCaptureSingleton(IAudioCaptureSingletonImpl^ runtime): CAudioCaptureSingletonBase(), _runtime(runtime) {} ~CAudioCaptureSingleton(){} virtual rho::String getDefaultID(){return "1";} // TODO: implement getDefaultID virtual rho::String getInitialDefaultID(){return "1";} // TODO: implement getInitialDefaultID virtual void setDefaultID(const rho::String& strID){} // TODO: implement setDefaultID //virtual void addCommandToQueue(rho::common::CInstanceClassFunctorBase* pFunctor){} // TODO: implement addCommandToQueue //virtual void callCommandInThread(rho::common::IRhoRunnable* pFunctor){} // TODO: implement callCommandInThread }; IAudioCaptureFactoryImpl^ CAudioCaptureFactory::_impl; IAudioCapture* CAudioCaptureFactory::createModuleByID(const rho::String& strID) { return new CAudioCaptureImpl(strID, _impl->getImpl()); } IAudioCaptureSingleton* CAudioCaptureFactory::createModuleSingleton() { return new CAudioCaptureSingleton(_impl->getSingletonImpl()); } } extern "C" void Init_AudioCapture_extension() { rho::CAudioCaptureFactory::setInstance( new rho::CAudioCaptureFactory() ); rho::Init_AudioCapture_API(); RHODESAPP().getExtManager().requireRubyFile("RhoAudioCaptureApi"); }