\hypertarget{_raspi_vid_y_u_v_8c}{}\section{/\+Volumes/\+W\+O\+R\+K\+\_\+\+I\+N\+\_\+\+P\+R\+O\+G\+R\+E\+S\+S/\+R\+A\+S\+P\+B\+E\+R\+R\+Y\+\_\+\+P\+I/github/userland/host\+\_\+applications/linux/apps/raspicam/\+Raspi\+Vid\+Y\+U\+V.c File Reference}
\label{_raspi_vid_y_u_v_8c}\index{/\+Volumes/\+W\+O\+R\+K\+\_\+\+I\+N\+\_\+\+P\+R\+O\+G\+R\+E\+S\+S/\+R\+A\+S\+P\+B\+E\+R\+R\+Y\+\_\+\+P\+I/github/userland/host\+\_\+applications/linux/apps/raspicam/\+Raspi\+Vid\+Y\+U\+V.\+c@{/\+Volumes/\+W\+O\+R\+K\+\_\+\+I\+N\+\_\+\+P\+R\+O\+G\+R\+E\+S\+S/\+R\+A\+S\+P\+B\+E\+R\+R\+Y\+\_\+\+P\+I/github/userland/host\+\_\+applications/linux/apps/raspicam/\+Raspi\+Vid\+Y\+U\+V.\+c}}
{\ttfamily \#include $<$stdio.\+h$>$}\\*
{\ttfamily \#include $<$stdlib.\+h$>$}\\*
{\ttfamily \#include $<$string.\+h$>$}\\*
{\ttfamily \#include $<$memory.\+h$>$}\\*
{\ttfamily \#include $<$sysexits.\+h$>$}\\*
{\ttfamily \#include \char`\"{}bcm\+\_\+host.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/vcos/vcos.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/mmal/mmal.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/mmal/mmal\+\_\+logging.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/mmal/mmal\+\_\+buffer.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/mmal/util/mmal\+\_\+util.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/mmal/util/mmal\+\_\+util\+\_\+params.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/mmal/util/mmal\+\_\+default\+\_\+components.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}interface/mmal/util/mmal\+\_\+connection.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}Raspi\+Cam\+Control.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}Raspi\+Preview.\+h\char`\"{}}\\*
{\ttfamily \#include \char`\"{}Raspi\+C\+L\+I.\+h\char`\"{}}\\*
{\ttfamily \#include $<$semaphore.\+h$>$}\\*
\subsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{struct_p_o_r_t___u_s_e_r_d_a_t_a}{P\+O\+R\+T\+\_\+\+U\+S\+E\+R\+D\+A\+T\+A}
\item 
struct \hyperlink{struct_r_a_s_p_i_v_i_d_y_u_v___s_t_a_t_e___s}{R\+A\+S\+P\+I\+V\+I\+D\+Y\+U\+V\+\_\+\+S\+T\+A\+T\+E\+\_\+\+S}
\end{DoxyCompactItemize}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\hypertarget{_raspi_vid_y_u_v_8c_a369266c24eacffb87046522897a570d5}{}\#define {\bfseries \+\_\+\+G\+N\+U\+\_\+\+S\+O\+U\+R\+C\+E}\label{_raspi_vid_y_u_v_8c_a369266c24eacffb87046522897a570d5}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_a698acb89e1bf5837b33c30ef35c30044}{}\#define {\bfseries V\+E\+R\+S\+I\+O\+N\+\_\+\+S\+T\+R\+I\+N\+G}~\char`\"{}v1.\+3.\+12\char`\"{}\label{_raspi_vid_y_u_v_8c_a698acb89e1bf5837b33c30ef35c30044}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_a8cc92011d6ebe2f6c3bd842467181fe0}{}\#define {\bfseries M\+M\+A\+L\+\_\+\+C\+A\+M\+E\+R\+A\+\_\+\+P\+R\+E\+V\+I\+E\+W\+\_\+\+P\+O\+R\+T}~0\label{_raspi_vid_y_u_v_8c_a8cc92011d6ebe2f6c3bd842467181fe0}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_ab8b496a6c64a35c25734f640ff2909db}{}\#define {\bfseries M\+M\+A\+L\+\_\+\+C\+A\+M\+E\+R\+A\+\_\+\+V\+I\+D\+E\+O\+\_\+\+P\+O\+R\+T}~1\label{_raspi_vid_y_u_v_8c_ab8b496a6c64a35c25734f640ff2909db}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_a6ea8994f409e4b977b3f49529bd8836e}{}\#define {\bfseries M\+M\+A\+L\+\_\+\+C\+A\+M\+E\+R\+A\+\_\+\+C\+A\+P\+T\+U\+R\+E\+\_\+\+P\+O\+R\+T}~2\label{_raspi_vid_y_u_v_8c_a6ea8994f409e4b977b3f49529bd8836e}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_aa58458e24843c25918857dfb95700aef}{}\#define {\bfseries V\+I\+D\+E\+O\+\_\+\+F\+R\+A\+M\+E\+\_\+\+R\+A\+T\+E\+\_\+\+N\+U\+M}~30\label{_raspi_vid_y_u_v_8c_aa58458e24843c25918857dfb95700aef}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_a005418ba77c3dfcbfe94731506490255}{}\#define {\bfseries V\+I\+D\+E\+O\+\_\+\+F\+R\+A\+M\+E\+\_\+\+R\+A\+T\+E\+\_\+\+D\+E\+N}~1\label{_raspi_vid_y_u_v_8c_a005418ba77c3dfcbfe94731506490255}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_a45ef30a3e903c0589d9c1191047fb960}{}\#define \hyperlink{_raspi_vid_y_u_v_8c_a45ef30a3e903c0589d9c1191047fb960}{V\+I\+D\+E\+O\+\_\+\+O\+U\+T\+P\+U\+T\+\_\+\+B\+U\+F\+F\+E\+R\+S\+\_\+\+N\+U\+M}~3\label{_raspi_vid_y_u_v_8c_a45ef30a3e903c0589d9c1191047fb960}

\begin{DoxyCompactList}\small\item\em Video render needs at least 2 buffers. \end{DoxyCompactList}\item 
\#define \hyperlink{_raspi_vid_y_u_v_8c_a23ee2e60d889280e6d7557855edc1aef}{W\+A\+I\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+N\+O\+N\+E}~0
\item 
\hypertarget{_raspi_vid_y_u_v_8c_a107dab6bd2d8aaacd0d452da306ee55c}{}\#define \hyperlink{_raspi_vid_y_u_v_8c_a107dab6bd2d8aaacd0d452da306ee55c}{W\+A\+I\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+T\+I\+M\+E\+D}~1\label{_raspi_vid_y_u_v_8c_a107dab6bd2d8aaacd0d452da306ee55c}

\begin{DoxyCompactList}\small\item\em Cycle between capture and pause for times specified. \end{DoxyCompactList}\item 
\hypertarget{_raspi_vid_y_u_v_8c_aaa803e6e7386c8d2f4f37ae33f068cf1}{}\#define \hyperlink{_raspi_vid_y_u_v_8c_aaa803e6e7386c8d2f4f37ae33f068cf1}{W\+A\+I\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+K\+E\+Y\+P\+R\+E\+S\+S}~2\label{_raspi_vid_y_u_v_8c_aaa803e6e7386c8d2f4f37ae33f068cf1}

\begin{DoxyCompactList}\small\item\em Switch between capture and pause on keypress. \end{DoxyCompactList}\item 
\hypertarget{_raspi_vid_y_u_v_8c_a04b8b223faf4c09fe9edda1ffdd2afdc}{}\#define \hyperlink{_raspi_vid_y_u_v_8c_a04b8b223faf4c09fe9edda1ffdd2afdc}{W\+A\+I\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+S\+I\+G\+N\+A\+L}~3\label{_raspi_vid_y_u_v_8c_a04b8b223faf4c09fe9edda1ffdd2afdc}

\begin{DoxyCompactList}\small\item\em Switch between capture and pause on signal. \end{DoxyCompactList}\item 
\hypertarget{_raspi_vid_y_u_v_8c_ac857ce880cd8dffe93862489209b261a}{}\#define \hyperlink{_raspi_vid_y_u_v_8c_ac857ce880cd8dffe93862489209b261a}{W\+A\+I\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+F\+O\+R\+E\+V\+E\+R}~4\label{_raspi_vid_y_u_v_8c_ac857ce880cd8dffe93862489209b261a}

\begin{DoxyCompactList}\small\item\em Run/record forever. \end{DoxyCompactList}\item 
\hypertarget{_raspi_vid_y_u_v_8c_aad1276a10255691d5d1b6ee899744210}{}\#define \hyperlink{_raspi_vid_y_u_v_8c_aad1276a10255691d5d1b6ee899744210}{Command\+Help}~0\label{_raspi_vid_y_u_v_8c_aad1276a10255691d5d1b6ee899744210}

\begin{DoxyCompactList}\small\item\em Command I\+D\textquotesingle{}s and Structure defining our command line options. \end{DoxyCompactList}\item 
\hypertarget{_raspi_vid_y_u_v_8c_a23426ba6b576d1b04df947f94bb797e8}{}\#define {\bfseries Command\+Width}~1\label{_raspi_vid_y_u_v_8c_a23426ba6b576d1b04df947f94bb797e8}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_ad5d81a9785e84731ec2d3d9301154445}{}\#define {\bfseries Command\+Height}~2\label{_raspi_vid_y_u_v_8c_ad5d81a9785e84731ec2d3d9301154445}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_acb7191506c0e3244de2ef6122b685e29}{}\#define {\bfseries Command\+Output}~3\label{_raspi_vid_y_u_v_8c_acb7191506c0e3244de2ef6122b685e29}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_a38a193491d99a525fc5553be50d32aed}{}\#define {\bfseries Command\+Verbose}~4\label{_raspi_vid_y_u_v_8c_a38a193491d99a525fc5553be50d32aed}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_acd7db803d94a3b35ace48c387ff39280}{}\#define {\bfseries Command\+Timeout}~5\label{_raspi_vid_y_u_v_8c_acd7db803d94a3b35ace48c387ff39280}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_af7e87beca7cd252571e5a60922259264}{}\#define {\bfseries Command\+Demo\+Mode}~6\label{_raspi_vid_y_u_v_8c_af7e87beca7cd252571e5a60922259264}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_a3f40fbad43c04bab258750e48db33583}{}\#define {\bfseries Command\+Framerate}~7\label{_raspi_vid_y_u_v_8c_a3f40fbad43c04bab258750e48db33583}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_a8f17254427ba9d0c6baf8d8395aef984}{}\#define {\bfseries Command\+Timed}~8\label{_raspi_vid_y_u_v_8c_a8f17254427ba9d0c6baf8d8395aef984}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_af4b07fae0f52e4b323d5623587b9020a}{}\#define {\bfseries Command\+Signal}~9\label{_raspi_vid_y_u_v_8c_af4b07fae0f52e4b323d5623587b9020a}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_abf1325fdb7fa052c2df5fcbf227165c8}{}\#define {\bfseries Command\+Keypress}~10\label{_raspi_vid_y_u_v_8c_abf1325fdb7fa052c2df5fcbf227165c8}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_ad0522fb92e7641c16f44b4047376c0ca}{}\#define {\bfseries Command\+Initial\+State}~11\label{_raspi_vid_y_u_v_8c_ad0522fb92e7641c16f44b4047376c0ca}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_a1ecb703a41dbfec83baf7dca9b5611f7}{}\#define {\bfseries Command\+Cam\+Select}~12\label{_raspi_vid_y_u_v_8c_a1ecb703a41dbfec83baf7dca9b5611f7}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_aeb41897c3ac5e5450ee4a70e8b7d6217}{}\#define {\bfseries Command\+Settings}~13\label{_raspi_vid_y_u_v_8c_aeb41897c3ac5e5450ee4a70e8b7d6217}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_ac12c379225ea75dad46e82cf4bd1e818}{}\#define {\bfseries Command\+Sensor\+Mode}~14\label{_raspi_vid_y_u_v_8c_ac12c379225ea75dad46e82cf4bd1e818}

\end{DoxyCompactItemize}
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\hypertarget{_raspi_vid_y_u_v_8c_a30863b73e78071b3c7c86e1ccc3e7792}{}typedef struct \hyperlink{struct_r_a_s_p_i_v_i_d_y_u_v___s_t_a_t_e___s}{R\+A\+S\+P\+I\+V\+I\+D\+Y\+U\+V\+\_\+\+S\+T\+A\+T\+E\+\_\+\+S} {\bfseries R\+A\+S\+P\+I\+V\+I\+D\+Y\+U\+V\+\_\+\+S\+T\+A\+T\+E}\label{_raspi_vid_y_u_v_8c_a30863b73e78071b3c7c86e1ccc3e7792}

\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
int \hyperlink{_raspi_vid_y_u_v_8c_ad6cc73ee106e56252e3e10278aa463b7}{mmal\+\_\+status\+\_\+to\+\_\+int} (M\+M\+A\+L\+\_\+\+S\+T\+A\+T\+U\+S\+\_\+\+T status)
\item 
int \hyperlink{_raspi_vid_y_u_v_8c_a217dbf8b442f20279ea00b898af96f52}{main} (int argc, const char $\ast$$\ast$argv)
\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\hypertarget{_raspi_vid_y_u_v_8c_a88469a10b5094c869d47b8e7b06f49e5}{}const int \hyperlink{_raspi_vid_y_u_v_8c_a88469a10b5094c869d47b8e7b06f49e5}{A\+B\+O\+R\+T\+\_\+\+I\+N\+T\+E\+R\+V\+A\+L} = 100\label{_raspi_vid_y_u_v_8c_a88469a10b5094c869d47b8e7b06f49e5}

\begin{DoxyCompactList}\small\item\em Interval at which we check for an failure abort during capture. \end{DoxyCompactList}\item 
\hypertarget{_raspi_vid_y_u_v_8c_ac9e47c346a25e2e7edd2c9b4ca5d0262}{}F\+I\+L\+E $\ast$ {\bfseries stderr}\label{_raspi_vid_y_u_v_8c_ac9e47c346a25e2e7edd2c9b4ca5d0262}

\item 
\hypertarget{_raspi_vid_y_u_v_8c_a05ef4243b9d275bdef6f8b4839ee03b6}{}F\+I\+L\+E $\ast$ {\bfseries stdout}\label{_raspi_vid_y_u_v_8c_a05ef4243b9d275bdef6f8b4839ee03b6}

\end{DoxyCompactItemize}


\subsection{Detailed Description}
Command line program to capture a camera video stream and save file as uncompressed Y\+U\+V420 data Also optionally display a preview/viewfinder of current camera input.

\begin{DoxyDate}{Date}
7th Jan 2014 \+: James Hughes
\end{DoxyDate}
Description

2 components are created; camera and preview. Camera component has three ports, preview, video and stills. Preview is connected using standard mmal connections, the video output is written straight to the file in Y\+U\+V 420 format via the requisite buffer callback. Still port is not used

We use the Raspi\+Cam\+Control code to handle the specific camera settings. We use the Raspi\+Preview code to handle the generic preview 

\subsection{Macro Definition Documentation}
\hypertarget{_raspi_vid_y_u_v_8c_a23ee2e60d889280e6d7557855edc1aef}{}\index{Raspi\+Vid\+Y\+U\+V.\+c@{Raspi\+Vid\+Y\+U\+V.\+c}!W\+A\+I\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+N\+O\+N\+E@{W\+A\+I\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+N\+O\+N\+E}}
\index{W\+A\+I\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+N\+O\+N\+E@{W\+A\+I\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+N\+O\+N\+E}!Raspi\+Vid\+Y\+U\+V.\+c@{Raspi\+Vid\+Y\+U\+V.\+c}}
\subsubsection[{W\+A\+I\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+N\+O\+N\+E}]{\setlength{\rightskip}{0pt plus 5cm}\#define W\+A\+I\+T\+\_\+\+M\+E\+T\+H\+O\+D\+\_\+\+N\+O\+N\+E~0}\label{_raspi_vid_y_u_v_8c_a23ee2e60d889280e6d7557855edc1aef}
Capture/\+Pause switch method Simply capture for time specified 

\subsection{Function Documentation}
\hypertarget{_raspi_vid_y_u_v_8c_a217dbf8b442f20279ea00b898af96f52}{}\index{Raspi\+Vid\+Y\+U\+V.\+c@{Raspi\+Vid\+Y\+U\+V.\+c}!main@{main}}
\index{main@{main}!Raspi\+Vid\+Y\+U\+V.\+c@{Raspi\+Vid\+Y\+U\+V.\+c}}
\subsubsection[{main}]{\setlength{\rightskip}{0pt plus 5cm}int main (
\begin{DoxyParamCaption}
\item[{int}]{argc, }
\item[{const char $\ast$$\ast$}]{argv}
\end{DoxyParamCaption}
)}\label{_raspi_vid_y_u_v_8c_a217dbf8b442f20279ea00b898af96f52}
main \hypertarget{_raspi_vid_y_u_v_8c_ad6cc73ee106e56252e3e10278aa463b7}{}\index{Raspi\+Vid\+Y\+U\+V.\+c@{Raspi\+Vid\+Y\+U\+V.\+c}!mmal\+\_\+status\+\_\+to\+\_\+int@{mmal\+\_\+status\+\_\+to\+\_\+int}}
\index{mmal\+\_\+status\+\_\+to\+\_\+int@{mmal\+\_\+status\+\_\+to\+\_\+int}!Raspi\+Vid\+Y\+U\+V.\+c@{Raspi\+Vid\+Y\+U\+V.\+c}}
\subsubsection[{mmal\+\_\+status\+\_\+to\+\_\+int}]{\setlength{\rightskip}{0pt plus 5cm}int mmal\+\_\+status\+\_\+to\+\_\+int (
\begin{DoxyParamCaption}
\item[{M\+M\+A\+L\+\_\+\+S\+T\+A\+T\+U\+S\+\_\+\+T}]{status}
\end{DoxyParamCaption}
)}\label{_raspi_vid_y_u_v_8c_ad6cc73ee106e56252e3e10278aa463b7}
Convert a M\+M\+A\+L status return value to a simple boolean of success A\+Lso displays a fault if code is not success


\begin{DoxyParams}{Parameters}
{\em status} & The error code to convert \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if status is sucess, 1 otherwise 
\end{DoxyReturn}
