From 6feedc95b0861513e13585422c1d68060165aef3 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 21 Feb 2015 20:23:59 +0000 Subject: [PATCH] Add new open stream function --- lib/PlaYUVerStream.cpp | 26 ++++++++++++++++++++++++++ lib/PlaYUVerStream.h | 1 + 2 files changed, 27 insertions(+) diff --git a/lib/PlaYUVerStream.cpp b/lib/PlaYUVerStream.cpp index 7acda98..80b7529 100644 --- a/lib/PlaYUVerStream.cpp +++ b/lib/PlaYUVerStream.cpp @@ -155,6 +155,32 @@ PlaYUVerStream::~PlaYUVerStream() close(); } +Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::string input_format_name, UInt frame_rate, Bool bInput ) +{ + UInt width; + UInt height; + Int input_format = -1; + + sscanf( resolution.c_str(), "%ux%u", &width, &height ); + if( width <= 0 || height <= 0 ) + { + return false; + } + for( UInt i = 0; i < PlaYUVerFrame::supportedPixelFormatListNames().size(); i++ ) + { + if( PlaYUVerFrame::supportedPixelFormatListNames()[i] == input_format_name ) + { + input_format = i; + break; + } + } + if( width > 0 && height > 0 && input_format >= 0 ) + { + return open( filename, width, height, input_format, frame_rate, bInput ); + } + return false; +} + Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput ) { if( m_bInit ) diff --git a/lib/PlaYUVerStream.h b/lib/PlaYUVerStream.h index 565d005..09245ef 100644 --- a/lib/PlaYUVerStream.h +++ b/lib/PlaYUVerStream.h @@ -115,6 +115,7 @@ public: END_OF_SEQ, }; + Bool open( std::string filename, std::string resolution, std::string input_format, UInt frame_rate, Bool bInput = true ); Bool open( std::string filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput = true ); Void close();