summaryrefslogtreecommitdiff
path: root/src/modules/emotion/gstreamer/emotion_alloc.c
blob: c4aae047b72b1786899154ce5a719f16d904487d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <Eina.h>
#include <Evas.h>
#include <Ecore.h>

#include <glib.h>
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/video/gstvideosink.h>

#ifdef HAVE_ECORE_X
# include <Ecore_X.h>
# ifdef HAVE_XOVERLAY_H
#  include <gst/interfaces/xoverlay.h>
# endif
#endif

#include "Emotion.h"
#include "emotion_gstreamer.h"

Emotion_Gstreamer_Buffer *
emotion_gstreamer_buffer_alloc(EvasVideoSinkPrivate *sink,
			       GstBuffer *buffer,
			       Eina_Bool preroll)
{
   Emotion_Gstreamer_Buffer *send;

   if (!sink->ev) return NULL;

   send = malloc(sizeof (Emotion_Gstreamer_Buffer));
   if (!send) return NULL;

   send->sink = sink;
   send->frame = gst_buffer_ref(buffer);
   send->preroll = preroll;
   send->force = EINA_FALSE;
   sink->ev->out++;
   send->ev = sink->ev;

   return send;
}

void
emotion_gstreamer_buffer_free(Emotion_Gstreamer_Buffer *send)
{
   send->ev->in++;

   if (send->ev->in == send->ev->out
       && send->ev->threads == NULL
       && send->ev->delete_me)
     send->ev->api->del(send->ev);

   gst_buffer_unref(send->frame);
   free(send);
}

Emotion_Gstreamer_Message *
emotion_gstreamer_message_alloc(Emotion_Gstreamer_Video *ev,
				GstMessage *msg)
{
   Emotion_Gstreamer_Message *send;

   if (!ev) return NULL;

   send = malloc(sizeof (Emotion_Gstreamer_Message));
   if (!send) return NULL;

   ev->out++;
   send->ev = ev;
   send->msg = gst_message_ref(msg);

   return send;
}

void
emotion_gstreamer_message_free(Emotion_Gstreamer_Message *send)
{
   send->ev->in++;

   if (send->ev->in == send->ev->out
       && send->ev->threads == NULL
       && send->ev->delete_me)
     send->ev->api->del(send->ev);

   gst_message_unref(send->msg);
   free(send);
}