Initialize Tizen 2.3
[framework/multimedia/gstreamer0.10-ffmpeg.git] / ext / ffmpeg / gstffmpegpipe.h
1 /* GStreamer
2  * Copyright (C) <2006> Mark Nauwelaerts <manauw@skynet.be>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20
21 #ifndef __GST_FFMPEGPIPE_H__
22 #define __GST_FFMPEGPIPE_H__
23
24 #include <gst/base/gstadapter.h>
25 #include "gstffmpeg.h"
26
27 G_BEGIN_DECLS
28
29 /* pipe protocol helpers */
30 #define GST_FFMPEG_PIPE_MUTEX_LOCK(m) G_STMT_START {                    \
31   GST_LOG_OBJECT (m, "locking tlock from thread %p", g_thread_self ()); \
32   g_mutex_lock (m->tlock);                                              \
33   GST_LOG_OBJECT (m, "locked tlock from thread %p", g_thread_self ());  \
34 } G_STMT_END
35
36 #define GST_FFMPEG_PIPE_MUTEX_UNLOCK(m) G_STMT_START {                    \
37   GST_LOG_OBJECT (m, "unlocking tlock from thread %p", g_thread_self ()); \
38   g_mutex_unlock (m->tlock);                                              \
39 } G_STMT_END
40
41 #define GST_FFMPEG_PIPE_WAIT(m) G_STMT_START {                          \
42   GST_LOG_OBJECT (m, "thread %p waiting", g_thread_self ());            \
43   g_cond_wait (m->cond, m->tlock);                                      \
44 } G_STMT_END
45
46 #define GST_FFMPEG_PIPE_SIGNAL(m) G_STMT_START {                        \
47   GST_LOG_OBJECT (m, "signalling from thread %p", g_thread_self ());    \
48   g_cond_signal (m->cond);                                              \
49 } G_STMT_END
50
51 typedef struct _GstFFMpegPipe GstFFMpegPipe;
52
53 struct _GstFFMpegPipe
54 {
55   /* lock for syncing */
56   GMutex *tlock;
57   /* with TLOCK */
58   /* signals counterpart thread to have a look */
59   GCond *cond;
60   /* seen eos */
61   gboolean eos;
62   /* flowreturn obtained by src task */
63   GstFlowReturn srcresult;
64   /* adpater collecting data */
65   GstAdapter *adapter;
66   /* amount needed in adapter by src task */
67   guint needed;
68 };
69
70 G_END_DECLS
71
72 #endif /* __GST_FFMPEGPIPE_H__ */