本文整理汇总了C++中GST_DEBUG函数的典型用法代码示例。如果您正苦于以下问题:C++ GST_DEBUG函数的具体用法?C++ GST_DEBUG怎么用?C++ GST_DEBUG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GST_DEBUG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: accept_socket
static gint accept_socket (HTTPServer *http_server)
{
struct epoll_event ee;
gint accepted_sock, ret;
struct sockaddr in_addr;
socklen_t in_len;
RequestData **request_data_pointer;
RequestData *request_data;
gint request_data_queue_len;
in_len = sizeof (in_addr);
for (;;) {
/* repeat accept until -1 returned */
accepted_sock = accept (http_server->listen_sock, &in_addr, &in_len);
if (accepted_sock == -1) {
if (( errno == EAGAIN) || (errno == EWOULDBLOCK)) {
/* We have processed all incoming connections. */
break;
} else {
GST_ERROR ("accept error %s", g_strerror (errno));
break;
}
}
g_mutex_lock (&(http_server->request_data_queue_mutex));
request_data_queue_len = g_queue_get_length (http_server->request_data_queue);
g_mutex_unlock (&(http_server->request_data_queue_mutex));
if (request_data_queue_len == 0) {
GST_ERROR ("event queue empty");
(void) close (accepted_sock);
//close_socket_gracefully (accepted_sock);
continue;
}
GST_INFO ("request from %s:%d, accepted_sock %d", get_address (in_addr), get_port (in_addr), accepted_sock);
http_server->total_click += 1;
int on = 1;
setsockopt (accepted_sock, SOL_TCP, TCP_CORK, &on, sizeof (on));
set_nonblock (accepted_sock);
g_mutex_lock (&(http_server->request_data_queue_mutex));
request_data_pointer = g_queue_pop_tail (http_server->request_data_queue);
g_mutex_unlock (&(http_server->request_data_queue_mutex));
if (request_data_pointer == NULL) {
GST_WARNING ("No NONE request, refuse this request.");
(void) close (accepted_sock);
//close_socket_gracefully (accepted_sock);
continue;
}
request_data = *request_data_pointer;
GST_DEBUG ("pop up request data, id %d, sock %d, events %d", request_data->id, accepted_sock, request_data->events);
/* clear events, there may be events from last request. */
request_data->events = 0;
request_data->client_addr = in_addr;
request_data->sock = accepted_sock;
request_data->birth_time = gst_clock_get_time (http_server->system_clock);
request_data->status = HTTP_CONNECTED;
request_data->request_length = 0;
ee.events = EPOLLIN | EPOLLOUT | EPOLLET;
ee.data.ptr = request_data_pointer;
ret = epoll_ctl (http_server->epollfd, EPOLL_CTL_ADD, accepted_sock, &ee);
if (ret == -1) {
GST_ERROR ("epoll_ctl add error %s sock %d", g_strerror (errno), accepted_sock);
request_data_release (http_server, request_data_pointer);
return -1;
} else {
GST_DEBUG ("pop request data, sock %d", request_data->sock);
}
}
return 0;
}
开发者ID:i4tv,项目名称:gstreamill,代码行数:72,代码来源:httpserver.c
示例2: gst_date_time_new_from_iso8601_string
/**
* gst_date_time_new_from_iso8601_string:
* @string: ISO 8601-formatted datetime string.
*
* Tries to parse common variants of ISO-8601 datetime strings into a
* #GstDateTime.
*
* Free-function: gst_date_time_unref
*
* Returns: (transfer full): a newly created #GstDateTime, or NULL on error
*/
GstDateTime *
gst_date_time_new_from_iso8601_string (const gchar * string)
{
gint year = -1, month = -1, day = -1, hour = -1, minute = -1;
gdouble second = -1.0;
gfloat tzoffset = 0.0;
guint64 usecs;
gint len, ret;
g_return_val_if_fail (string != NULL, NULL);
GST_DEBUG ("Parsing '%s' into a datetime", string);
len = strlen (string);
if (len < 4 || !g_ascii_isdigit (string[0]) || !g_ascii_isdigit (string[1])
|| !g_ascii_isdigit (string[2]) || !g_ascii_isdigit (string[3]))
return NULL;
ret = sscanf (string, "%04d-%02d-%02d", &year, &month, &day);
if (ret == 0)
return NULL;
if (ret == 3 && day <= 0) {
ret = 2;
day = -1;
}
if (ret >= 2 && month <= 0) {
ret = 1;
month = day = -1;
}
if (ret >= 1 && year <= 0)
return NULL;
else if (ret >= 1 && len < 16)
/* YMD is 10 chars. XMD + HM will be 16 chars. if it is less,
* it make no sense to continue. We will stay with YMD. */
goto ymd;
string += 10;
/* Exit if there is no expeceted value on this stage */
if (!(*string == 'T' || *string == '-' || *string == ' '))
goto ymd;
/* if hour or minute fails, then we will use onlly ymd. */
hour = g_ascii_strtoull (string + 1, (gchar **) & string, 10);
if (hour > 24 || *string != ':')
goto ymd;
/* minute */
minute = g_ascii_strtoull (string + 1, (gchar **) & string, 10);
if (minute > 59)
goto ymd;
/* second */
if (*string == ':') {
second = g_ascii_strtoull (string + 1, (gchar **) & string, 10);
/* if we fail here, we still can reuse hour and minute. We
* will still attempt to parse any timezone information */
if (second > 59) {
second = -1.0;
} else {
/* microseconds */
if (*string == '.' || *string == ',') {
const gchar *usec_start = string + 1;
guint digits;
usecs = g_ascii_strtoull (string + 1, (gchar **) & string, 10);
if (usecs != G_MAXUINT64 && string > usec_start) {
digits = (guint) (string - usec_start);
second += (gdouble) usecs / pow (10.0, digits);
}
}
}
}
if (*string == 'Z')
goto ymd_hms;
else {
/* reuse some code from gst-plugins-base/gst-libs/gst/tag/gstxmptag.c */
gint gmt_offset_hour = -1, gmt_offset_min = -1, gmt_offset = -1;
gchar *plus_pos = NULL;
gchar *neg_pos = NULL;
gchar *pos = NULL;
GST_LOG ("Checking for timezone information");
//.........这里部分代码省略.........
开发者ID:PeterXu,项目名称:gst-mobile,代码行数:101,代码来源:gstdatetime.c
示例3: flush_data
static void
flush_data (GstRtpQDM2Depay * depay)
{
guint i;
guint avail;
if ((avail = gst_adapter_available (depay->adapter)))
gst_adapter_flush (depay->adapter, avail);
GST_DEBUG ("Flushing %d packets", depay->nbpackets);
for (i = 0; depay->packets[i]; i++) {
QDM2Packet *pack = depay->packets[i];
guint32 crc = 0;
int i = 0;
GstBuffer *buf;
guint8 *data;
/* CRC is the sum of everything (including first bytes) */
data = pack->data;
if (G_UNLIKELY (data == NULL))
continue;
/* If the packet size is bigger than 0xff, we need 2 bytes to store the size */
if (depay->packetsize > 0xff) {
/* Expanded size 0x02 | 0x80 */
data[0] = 0x82;
GST_WRITE_UINT16_BE (data + 1, depay->packetsize - 3);
} else {
data[0] = 0x2;
data[1] = depay->packetsize - 2;
}
/* Calculate CRC */
for (; i < depay->packetsize; i++)
crc += data[i];
GST_DEBUG ("CRC is 0x%x", crc);
/* Write CRC */
if (depay->packetsize > 0xff)
GST_WRITE_UINT16_BE (data + 3, crc);
else
GST_WRITE_UINT16_BE (data + 2, crc);
GST_MEMDUMP ("Extracted packet", data, depay->packetsize);
buf = gst_buffer_new ();
gst_buffer_append_memory (buf,
gst_memory_new_wrapped (0, data, depay->packetsize, 0,
depay->packetsize, data, g_free));
gst_adapter_push (depay->adapter, buf);
if (pack->data) {
pack->data = NULL;
}
}
}
开发者ID:lubing521,项目名称:gst-embedded-builder,代码行数:61,代码来源:gstrtpqdmdepay.c
示例4: gst_mpg123_audio_dec_class_init
static void
gst_mpg123_audio_dec_class_init (GstMpg123AudioDecClass * klass)
{
GstAudioDecoderClass *base_class;
GstElementClass *element_class;
GstPadTemplate *src_template, *sink_template;
int error;
GST_DEBUG_CATEGORY_INIT (mpg123_debug, "mpg123", 0, "mpg123 mp3 decoder");
base_class = GST_AUDIO_DECODER_CLASS (klass);
element_class = GST_ELEMENT_CLASS (klass);
gst_element_class_set_static_metadata (element_class,
"mpg123 mp3 decoder",
"Codec/Decoder/Audio",
"Decodes mp3 streams using the mpg123 library",
"Carlos Rafael Giani <[email protected]>");
/* Not using static pad template for srccaps, since the comma-separated list
* of formats needs to be created depending on whatever mpg123 supports */
{
const int *format_list;
const long *rates_list;
size_t num, i;
GString *s;
GstCaps *src_template_caps;
s = g_string_new ("audio/x-raw, ");
mpg123_encodings (&format_list, &num);
g_string_append (s, "format = { ");
for (i = 0; i < num; ++i) {
switch (format_list[i]) {
case MPG123_ENC_SIGNED_16:
g_string_append (s, (i > 0) ? ", " : "");
g_string_append (s, GST_AUDIO_NE (S16));
break;
case MPG123_ENC_UNSIGNED_16:
g_string_append (s, (i > 0) ? ", " : "");
g_string_append (s, GST_AUDIO_NE (U16));
break;
case MPG123_ENC_SIGNED_24:
g_string_append (s, (i > 0) ? ", " : "");
g_string_append (s, GST_AUDIO_NE (S24));
break;
case MPG123_ENC_UNSIGNED_24:
g_string_append (s, (i > 0) ? ", " : "");
g_string_append (s, GST_AUDIO_NE (U24));
break;
case MPG123_ENC_SIGNED_32:
g_string_append (s, (i > 0) ? ", " : "");
g_string_append (s, GST_AUDIO_NE (S32));
break;
case MPG123_ENC_UNSIGNED_32:
g_string_append (s, (i > 0) ? ", " : "");
g_string_append (s, GST_AUDIO_NE (U32));
break;
case MPG123_ENC_FLOAT_32:
g_string_append (s, (i > 0) ? ", " : "");
g_string_append (s, GST_AUDIO_NE (F32));
break;
default:
GST_DEBUG ("Ignoring mpg123 format %d", format_list[i]);
break;
}
}
g_string_append (s, " }, ");
mpg123_rates (&rates_list, &num);
g_string_append (s, "rate = (int) { ");
for (i = 0; i < num; ++i) {
g_string_append_printf (s, "%s%lu", (i > 0) ? ", " : "", rates_list[i]);
}
g_string_append (s, "}, ");
g_string_append (s, "channels = (int) [ 1, 2 ], ");
g_string_append (s, "layout = (string) interleaved");
src_template_caps = gst_caps_from_string (s->str);
src_template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
src_template_caps);
g_string_free (s, TRUE);
}
sink_template = gst_static_pad_template_get (&static_sink_template);
gst_element_class_add_pad_template (element_class, sink_template);
gst_element_class_add_pad_template (element_class, src_template);
base_class->start = GST_DEBUG_FUNCPTR (gst_mpg123_audio_dec_start);
base_class->stop = GST_DEBUG_FUNCPTR (gst_mpg123_audio_dec_stop);
base_class->handle_frame =
GST_DEBUG_FUNCPTR (gst_mpg123_audio_dec_handle_frame);
base_class->set_format = GST_DEBUG_FUNCPTR (gst_mpg123_audio_dec_set_format);
base_class->flush = GST_DEBUG_FUNCPTR (gst_mpg123_audio_dec_flush);
error = mpg123_init ();
if (G_UNLIKELY (error != MPG123_OK))
//.........这里部分代码省略.........
开发者ID:flavioribeiro,项目名称:gst-plugins-bad,代码行数:101,代码来源:gstmpg123audiodec.c
示例5: cam_device_open
gboolean
cam_device_open (CamDevice * device, const char *filename)
{
ca_caps_t ca_caps;
int ret;
int i;
int count = 10;
g_return_val_if_fail (device != NULL, FALSE);
g_return_val_if_fail (device->state == CAM_DEVICE_STATE_CLOSED, FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
GST_INFO ("opening ca device %s", filename);
ret = open (filename, O_RDWR);
if (ret == -1) {
GST_ERROR ("can't open ca device: %s", strerror (errno));
return FALSE;
}
GST_DEBUG ("Successfully opened device %s", filename);
device->fd = ret;
ret = ioctl (device->fd, CA_RESET);
g_usleep (G_USEC_PER_SEC / 10);
while (TRUE) {
/* get the capabilities of the CA */
ret = ioctl (device->fd, CA_GET_CAP, &ca_caps);
if (ret == -1) {
GST_ERROR ("CA_GET_CAP ioctl failed: %s", strerror (errno));
reset_state (device);
return FALSE;
}
if (ca_caps.slot_num > 0)
break;
if (!count) {
GST_ERROR ("CA_GET_CAP succeeded but not slots");
reset_state (device);
return FALSE;
}
count--;
g_usleep (G_USEC_PER_SEC / 5);
}
device->tl = cam_tl_new (device->fd);
device->sl = cam_sl_new (device->tl);
device->al = cam_al_new (device->sl);
device->mgr = cam_resource_manager_new ();
cam_al_install (device->al, CAM_AL_APPLICATION (device->mgr));
device->info = cam_application_info_new ();
cam_al_install (device->al, CAM_AL_APPLICATION (device->info));
device->cas = cam_conditional_access_new ();
cam_al_install (device->al, CAM_AL_APPLICATION (device->cas));
/* open a connection to each slot */
for (i = 0; i < ca_caps.slot_num; ++i) {
CamTLConnection *connection;
ret = cam_tl_create_connection (device->tl, i, &connection);
if (CAM_FAILED (ret)) {
/* just ignore the slot, error out later only if no connection has been
* established */
GST_WARNING ("connection to slot %d failed, error: %d", i, ret);
continue;
}
}
if (g_hash_table_size (device->tl->connections) == 0) {
GST_ERROR ("couldn't connect to any slot");
reset_state (device);
return FALSE;
}
device->state = CAM_DEVICE_STATE_OPEN;
device->filename = g_strdup (filename);
/* poll each connection to initiate the protocol */
cam_tl_read_all (device->tl, TRUE);
return TRUE;
}
开发者ID:cbetz421,项目名称:gst-plugins-bad,代码行数:88,代码来源:camdevice.c
示例6: gst_rtmp_src_create
/*
* Read a new buffer from src->reqoffset, takes care of events
* and seeking and such.
*/
static GstFlowReturn
gst_rtmp_src_create (GstPushSrc * pushsrc, GstBuffer ** buffer)
{
GstRTMPSrc *src;
GstBuffer *buf;
GstMapInfo map;
guint8 *data;
guint todo;
gsize bsize;
int read;
int size;
src = GST_RTMP_SRC (pushsrc);
g_return_val_if_fail (src->rtmp != NULL, GST_FLOW_ERROR);
size = GST_BASE_SRC_CAST (pushsrc)->blocksize;
GST_DEBUG ("reading from %" G_GUINT64_FORMAT
", size %u", src->cur_offset, size);
buf = gst_buffer_new_allocate (NULL, size, NULL);
if (G_UNLIKELY (buf == NULL)) {
GST_ERROR_OBJECT (src, "Failed to allocate %u bytes", size);
return GST_FLOW_ERROR;
}
bsize = todo = size;
gst_buffer_map (buf, &map, GST_MAP_WRITE);
data = map.data;
read = bsize = 0;
while (todo > 0) {
read = RTMP_Read (src->rtmp, (char *) data, todo);
if (G_UNLIKELY (read == 0 && todo == size)) {
goto eos;
} else if (G_UNLIKELY (read == 0)) {
todo = 0;
break;
}
if (G_UNLIKELY (read < 0))
goto read_failed;
if (read < todo) {
data += read;
todo -= read;
bsize += read;
} else {
bsize += todo;
todo = 0;
}
GST_LOG (" got size %d", read);
}
gst_buffer_unmap (buf, &map);
gst_buffer_resize (buf, 0, bsize);
if (src->discont) {
GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
src->discont = FALSE;
}
GST_BUFFER_TIMESTAMP (buf) = src->last_timestamp;
GST_BUFFER_OFFSET (buf) = src->cur_offset;
src->cur_offset += size;
if (src->last_timestamp == GST_CLOCK_TIME_NONE)
src->last_timestamp = src->rtmp->m_mediaStamp * GST_MSECOND;
else
src->last_timestamp =
MAX (src->last_timestamp, src->rtmp->m_mediaStamp * GST_MSECOND);
GST_LOG_OBJECT (src, "Created buffer of size %u at %" G_GINT64_FORMAT
" with timestamp %" GST_TIME_FORMAT, size, GST_BUFFER_OFFSET (buf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
/* we're done, return the buffer */
*buffer = buf;
return GST_FLOW_OK;
read_failed:
{
gst_buffer_unref (buf);
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("Failed to read data"));
return GST_FLOW_ERROR;
}
eos:
{
gst_buffer_unref (buf);
if (src->cur_offset == 0) {
GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
("Failed to read any data from stream, check your URL"));
return GST_FLOW_ERROR;
//.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:gst-plugins-bad,代码行数:101,代码来源:gstrtmpsrc.c
示例7: gst_ffmpegvidenc_register
gboolean
gst_ffmpegvidenc_register (GstPlugin * plugin)
{
GTypeInfo typeinfo = {
sizeof (GstFFMpegVidEncClass),
(GBaseInitFunc) gst_ffmpegvidenc_base_init,
NULL,
(GClassInitFunc) gst_ffmpegvidenc_class_init,
NULL,
NULL,
sizeof (GstFFMpegVidEnc),
0,
(GInstanceInitFunc) gst_ffmpegvidenc_init,
};
GType type;
AVCodec *in_plugin;
GST_LOG ("Registering encoders");
/* build global ffmpeg param/property info */
gst_ffmpeg_cfg_init ();
in_plugin = av_codec_next (NULL);
while (in_plugin) {
gchar *type_name;
/* Skip non-AV codecs */
if (in_plugin->type != AVMEDIA_TYPE_VIDEO)
goto next;
/* no quasi codecs, please */
if (in_plugin->id == AV_CODEC_ID_RAWVIDEO ||
in_plugin->id == AV_CODEC_ID_V210 ||
in_plugin->id == AV_CODEC_ID_V210X ||
in_plugin->id == AV_CODEC_ID_R210
|| in_plugin->id == AV_CODEC_ID_ZLIB) {
goto next;
}
/* No encoders depending on external libraries (we don't build them, but
* people who build against an external ffmpeg might have them.
* We have native gstreamer plugins for all of those libraries anyway. */
if (!strncmp (in_plugin->name, "lib", 3)) {
GST_DEBUG
("Not using external library encoder %s. Use the gstreamer-native ones instead.",
in_plugin->name);
goto next;
}
/* only video encoders */
if (!av_codec_is_encoder (in_plugin)
|| in_plugin->type != AVMEDIA_TYPE_VIDEO)
goto next;
/* FIXME : We should have a method to know cheaply whether we have a mapping
* for the given plugin or not */
GST_DEBUG ("Trying plugin %s [%s]", in_plugin->name, in_plugin->long_name);
/* no codecs for which we're GUARANTEED to have better alternatives */
if (!strcmp (in_plugin->name, "gif")) {
GST_LOG ("Ignoring encoder %s", in_plugin->name);
goto next;
}
/* construct the type */
type_name = g_strdup_printf ("avenc_%s", in_plugin->name);
type = g_type_from_name (type_name);
if (!type) {
/* create the glib type now */
type =
g_type_register_static (GST_TYPE_VIDEO_ENCODER, type_name, &typeinfo,
0);
g_type_set_qdata (type, GST_FFENC_PARAMS_QDATA, (gpointer) in_plugin);
{
static const GInterfaceInfo preset_info = {
NULL,
NULL,
NULL
};
g_type_add_interface_static (type, GST_TYPE_PRESET, &preset_info);
}
}
if (!gst_element_register (plugin, type_name, GST_RANK_SECONDARY, type)) {
g_free (type_name);
return FALSE;
}
g_free (type_name);
next:
in_plugin = av_codec_next (in_plugin);
}
//.........这里部分代码省略.........
开发者ID:achristensen07,项目名称:gst_vs,代码行数:101,代码来源:gstavvidenc.c
示例8: _gst_glsl_shader_string_find_version
/* returns the pointer in @str to the #version declaration */
const gchar *
_gst_glsl_shader_string_find_version (const gchar * str)
{
gboolean sl_comment = FALSE;
gboolean ml_comment = FALSE;
gboolean newline = TRUE;
gint i = 0;
_init_debug ();
/* search for #version while allowing for preceeding comments/whitespace as
* permitted by the GLSL specification */
while (str && str[i] != '\0' && i < 1024) {
if (str[i] == '\n' || str[i] == '\r') {
newline = TRUE;
sl_comment = FALSE;
i++;
continue;
}
if (g_ascii_isspace (str[i]))
goto next;
if (sl_comment)
goto next;
if (ml_comment) {
if (g_strstr_len (&str[i], 2, "*/")) {
ml_comment = FALSE;
i++;
}
goto next;
}
if (g_strstr_len (&str[i], 2, "//")) {
sl_comment = TRUE;
i++;
goto next;
}
if (g_strstr_len (&str[i], 2, "/*")) {
ml_comment = TRUE;
i++;
goto next;
}
if (str[i] == '#') {
if (newline && _check_valid_version_preprocessor_string (&str[i])) {
GST_DEBUG ("found #version declaration at index %i", i);
return &str[i];
}
break;
}
next:
newline = FALSE;
i++;
}
GST_DEBUG ("no #version declaration found in the first 1K");
return NULL;
}
开发者ID:alessandrod,项目名称:gst-plugins-bad,代码行数:64,代码来源:gstglsl.c
示例9: gst_goom_chain
static GstFlowReturn
gst_goom_chain (GstPad * pad, GstBuffer * buffer)
{
GstGoom *goom;
GstFlowReturn ret;
GstBuffer *outbuf = NULL;
goom = GST_GOOM (gst_pad_get_parent (pad));
/* If we don't have an output format yet, preallocate a buffer to try and
* set one */
if (GST_PAD_CAPS (goom->srcpad) == NULL) {
ret = get_buffer (goom, &outbuf);
if (ret != GST_FLOW_OK) {
gst_buffer_unref (buffer);
goto beach;
}
}
/* don't try to combine samples from discont buffer */
if (GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DISCONT)) {
gst_adapter_clear (goom->adapter);
goom->next_ts = -1;
}
/* Match timestamps from the incoming audio */
if (GST_BUFFER_TIMESTAMP (buffer) != GST_CLOCK_TIME_NONE)
goom->next_ts = GST_BUFFER_TIMESTAMP (buffer);
GST_DEBUG_OBJECT (goom,
"Input buffer has %d samples, time=%" G_GUINT64_FORMAT,
GST_BUFFER_SIZE (buffer) / goom->bps, GST_BUFFER_TIMESTAMP (buffer));
/* Collect samples until we have enough for an output frame */
gst_adapter_push (goom->adapter, buffer);
ret = GST_FLOW_OK;
while (TRUE) {
const guint16 *data;
gboolean need_skip;
guchar *out_frame;
gint i, c;
guint avail, to_flush;
Message m;
avail = gst_adapter_available (goom->adapter);
GST_DEBUG_OBJECT (goom, "avail now %u", avail);
/* we need GOOM_SAMPLES to get a meaningful result from goom. */
if (avail < (GOOM_SAMPLES * goom->bps))
break;
/* we also need enough samples to produce one frame at least */
if (avail < goom->bpf)
break;
GST_DEBUG_OBJECT (goom, "processing buffer");
if (goom->next_ts != -1) {
gint64 qostime;
qostime = gst_segment_to_running_time (&goom->segment, GST_FORMAT_TIME,
goom->next_ts);
GST_OBJECT_LOCK (goom);
/* check for QoS, don't compute buffers that are known to be late */
need_skip = goom->earliest_time != -1 && qostime <= goom->earliest_time;
GST_OBJECT_UNLOCK (goom);
if (need_skip) {
GST_WARNING_OBJECT (goom,
"QoS: skip ts: %" GST_TIME_FORMAT ", earliest: %" GST_TIME_FORMAT,
GST_TIME_ARGS (qostime), GST_TIME_ARGS (goom->earliest_time));
goto skip;
}
}
/* get next GOOM_SAMPLES, we have at least this amount of samples */
data =
(const guint16 *) gst_adapter_peek (goom->adapter,
GOOM_SAMPLES * goom->bps);
if (goom->channels == 2) {
for (i = 0; i < GOOM_SAMPLES; i++) {
goom->datain[0][i] = *data++;
goom->datain[1][i] = *data++;
}
} else {
for (i = 0; i < GOOM_SAMPLES; i++) {
goom->datain[0][i] = *data;
goom->datain[1][i] = *data++;
}
}
/* alloc a buffer if we don't have one yet, this happens
* when we pushed a buffer in this while loop before */
if (outbuf == NULL) {
ret = get_buffer (goom, &outbuf);
//.........这里部分代码省略.........
开发者ID:cwilgenhoff,项目名称:glbcpphack,代码行数:101,代码来源:gstgoom.c
示例10: gst_sdlv_process_events
/* Process pending events. Call with ->lock held */
static void
gst_sdlv_process_events (GstSDLVideoSink * sdlvideosink)
{
SDL_Event event;
int numevents;
char *keysym = NULL;
do {
SDL_PumpEvents ();
numevents = SDL_PeepEvents (&event, 1, SDL_GETEVENT,
SDL_KEYDOWNMASK | SDL_KEYUPMASK |
SDL_MOUSEMOTIONMASK | SDL_MOUSEBUTTONDOWNMASK |
SDL_MOUSEBUTTONUPMASK | SDL_QUITMASK | SDL_VIDEORESIZEMASK);
if (numevents > 0 && (event.type == SDL_KEYUP || event.type == SDL_KEYDOWN)) {
keysym = SDL_GetKeyName (event.key.keysym.sym);
}
if (numevents > 0) {
g_mutex_unlock (sdlvideosink->lock);
switch (event.type) {
case SDL_MOUSEMOTION:
gst_navigation_send_mouse_event (GST_NAVIGATION (sdlvideosink),
"mouse-move", 0, event.motion.x, event.motion.y);
break;
case SDL_MOUSEBUTTONDOWN:
gst_navigation_send_mouse_event (GST_NAVIGATION (sdlvideosink),
"mouse-button-press",
event.button.button, event.button.x, event.button.y);
break;
case SDL_MOUSEBUTTONUP:
gst_navigation_send_mouse_event (GST_NAVIGATION (sdlvideosink),
"mouse-button-release",
event.button.button, event.button.x, event.button.y);
break;
case SDL_KEYUP:
GST_DEBUG ("key press event %s !",
SDL_GetKeyName (event.key.keysym.sym));
gst_navigation_send_key_event (GST_NAVIGATION (sdlvideosink),
"key-release", keysym);
break;
case SDL_KEYDOWN:
if (SDLK_ESCAPE != event.key.keysym.sym) {
GST_DEBUG ("key press event %s !",
SDL_GetKeyName (event.key.keysym.sym));
gst_navigation_send_key_event (GST_NAVIGATION (sdlvideosink),
"key-press", keysym);
break;
} else {
/* fall through */
}
case SDL_QUIT:
sdlvideosink->running = FALSE;
GST_ELEMENT_ERROR (sdlvideosink, RESOURCE, OPEN_WRITE,
("Video output device is gone."),
("We were running fullscreen and user "
"pressed the ESC key, stopping playback."));
break;
case SDL_VIDEORESIZE:
/* create a SDL window of the size requested by the user */
g_mutex_lock (sdlvideosink->lock);
GST_VIDEO_SINK_WIDTH (sdlvideosink) = event.resize.w;
GST_VIDEO_SINK_HEIGHT (sdlvideosink) = event.resize.h;
gst_sdlvideosink_create (sdlvideosink);
g_mutex_unlock (sdlvideosink->lock);
break;
}
g_mutex_lock (sdlvideosink->lock);
}
} while (numevents > 0);
}
开发者ID:wang-zhao,项目名称:gstreamer-win,代码行数:72,代码来源:sdlvideosink.c
示例11: gst_sdlvideosink_create
/* Must be called with the sdl lock held */
static gboolean
gst_sdlvideosink_create (GstSDLVideoSink * sdlvideosink)
{
if (GST_VIDEO_SINK_HEIGHT (sdlvideosink) <= 0)
GST_VIDEO_SINK_HEIGHT (sdlvideosink) = sdlvideosink->height;
if (GST_VIDEO_SINK_WIDTH (sdlvideosink) <= 0)
GST_VIDEO_SINK_WIDTH (sdlvideosink) = sdlvideosink->width;
gst_sdlvideosink_destroy (sdlvideosink);
if (sdlvideosink->is_xwindows && !sdlvideosink->xwindow_id) {
g_mutex_unlock (sdlvideosink->lock);
gst_x_overlay_prepare_xwindow_id (GST_X_OVERLAY (sdlvideosink));
g_mutex_lock (sdlvideosink->lock);
}
/* create a SDL window of the size requested by the user */
if (sdlvideosink->full_screen) {
sdlvideosink->screen =
SDL_SetVideoMode (GST_VIDEO_SINK_WIDTH (sdlvideosink),
GST_VIDEO_SINK_HEIGHT (sdlvideosink), 0,
SDL_SWSURFACE | SDL_FULLSCREEN);
} else {
sdlvideosink->screen =
SDL_SetVideoMode (GST_VIDEO_SINK_WIDTH (sdlvideosink),
GST_VIDEO_SINK_HEIGHT (sdlvideosink), 0, SDL_HWSURFACE | SDL_RESIZABLE);
}
if (sdlvideosink->screen == NULL)
goto no_screen;
/* create a new YUV overlay */
sdlvideosink->overlay = SDL_CreateYUVOverlay (sdlvideosink->width,
sdlvideosink->height, sdlvideosink->format, sdlvideosink->screen);
if (sdlvideosink->overlay == NULL)
goto no_overlay;
GST_DEBUG ("Using a %dx%d %dbpp SDL screen with a %dx%d \'%"
GST_FOURCC_FORMAT "\' YUV overlay", GST_VIDEO_SINK_WIDTH (sdlvideosink),
GST_VIDEO_SINK_HEIGHT (sdlvideosink),
sdlvideosink->screen->format->BitsPerPixel, sdlvideosink->width,
sdlvideosink->height, GST_FOURCC_ARGS (sdlvideosink->format));
sdlvideosink->rect.x = 0;
sdlvideosink->rect.y = 0;
sdlvideosink->rect.w = GST_VIDEO_SINK_WIDTH (sdlvideosink);
sdlvideosink->rect.h = GST_VIDEO_SINK_HEIGHT (sdlvideosink);
/*SDL_DisplayYUVOverlay (sdlvideosink->overlay, &(sdlvideosink->rect)); */
GST_DEBUG ("sdlvideosink: setting %08x (%" GST_FOURCC_FORMAT ")",
sdlvideosink->format, GST_FOURCC_ARGS (sdlvideosink->format));
return TRUE;
/* ERRORS */
no_screen:
{
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
("SDL: Couldn't set %dx%d: %s", GST_VIDEO_SINK_WIDTH (sdlvideosink),
GST_VIDEO_SINK_HEIGHT (sdlvideosink), SDL_GetError ()));
return FALSE;
}
no_overlay:
{
GST_ELEMENT_ERROR (sdlvideosink, LIBRARY, TOO_LAZY, (NULL),
("SDL: Couldn't create SDL YUV overlay (%dx%d \'%" GST_FOURCC_FORMAT
"\'): %s", sdlvideosink->width, sdlvideosink->height,
GST_FOURCC_ARGS (sdlvideosink->format), SDL_GetError ()));
return FALSE;
}
}
开发者ID:wang-zhao,项目名称:gstreamer-win,代码行数:73,代码来源:sdlvideosink.c
示例12: gst_dv1394src_iso_receive
static int
gst_dv1394src_iso_receive (raw1394handle_t handle, int channel, size_t len,
quadlet_t * data)
{
GstDV1394Src *dv1394src = gst_dv1394src_from_raw1394handle (handle);
if (len > 16) {
/*
the following code taken from kino-0.51 (Dan Dennedy/Charles Yates)
Kindly relicensed under the LGPL. See the commit log for version 1.6 of
this file in CVS.
*/
unsigned char *p = (unsigned char *) &data[3];
int section_type = p[0] >> 5; /* section type is in bits 5 - 7 */
int dif_sequence = p[1] >> 4; /* dif sequence number is in bits 4 - 7 */
int dif_block = p[2];
/* if we are at the beginning of a frame,
we set buf=frame, and alloc a new buffer for frame
*/
if (section_type == 0 && dif_sequence == 0) { // dif header
if (!GST_PAD_CAPS (GST_BASE_SRC_PAD (dv1394src))) {
GstCaps *caps;
// figure format (NTSC/PAL)
if (p[3] & 0x80) {
// PAL
dv1394src->frame_size = PAL_FRAMESIZE;
dv1394src->frame_rate = PAL_FRAMERATE;
GST_DEBUG ("PAL data");
caps = gst_caps_new_simple ("video/x-dv",
"format", G_TYPE_STRING, "PAL",
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
} else {
// NTSC (untested)
dv1394src->frame_size = NTSC_FRAMESIZE;
dv1394src->frame_rate = NTSC_FRAMERATE;
GST_DEBUG
("NTSC data [untested] - please report success/failure to <[email protected]>");
caps = gst_caps_new_simple ("video/x-dv",
"format", G_TYPE_STRING, "NTSC",
"systemstream", G_TYPE_BOOLEAN, TRUE, NULL);
}
gst_pad_set_caps (GST_BASE_SRC_PAD (dv1394src), caps);
gst_caps_unref (caps);
}
// drop last frame when not complete
if (!dv1394src->drop_incomplete
|| dv1394src->bytes_in_frame == dv1394src->frame_size) {
dv1394src->buf = dv1394src->frame;
} else {
GST_INFO_OBJECT (GST_ELEMENT (dv1394src), "incomplete frame dropped");
g_signal_emit (G_OBJECT (dv1394src),
gst_dv1394src_signals[SIGNAL_FRAME_DROPPED], 0);
if (dv1394src->frame) {
gst_buffer_unref (dv1394src->frame);
}
}
if ((dv1394src->frame_sequence + 1) % (dv1394src->skip +
dv1394src->consecutive) < dv1394src->consecutive) {
GstBuffer *buf;
gint64 i64;
buf = gst_buffer_new_and_alloc (dv1394src->frame_size);
/* fill in offset, duration, timestamp */
GST_BUFFER_OFFSET (buf) = dv1394src->frame_sequence;
dv1394src->frame = buf;
}
dv1394src->frame_sequence++;
dv1394src->bytes_in_frame = 0;
}
if (dv1394src->frame != NULL) {
guint8 *data = GST_BUFFER_DATA (dv1394src->frame);
switch (section_type) {
case 0: /* 1 Header block */
/* p[3] |= 0x80; // hack to force PAL data */
memcpy (data + dif_sequence * 150 * 80, p, 480);
break;
case 1: /* 2 Subcode blocks */
memcpy (data + dif_sequence * 150 * 80 + (1 + dif_block) * 80, p,
480);
break;
case 2: /* 3 VAUX blocks */
memcpy (data + dif_sequence * 150 * 80 + (3 + dif_block) * 80, p,
480);
break;
case 3: /* 9 Audio blocks interleaved with video */
memcpy (data + dif_sequence * 150 * 80 + (6 + dif_block * 16) * 80, p,
480);
break;
case 4: /* 135 Video blocks interleaved with audio */
memcpy (data + dif_sequence * 150 * 80 + (7 + (dif_block / 15) +
//.........这里部分代码省略.........
开发者ID:DylanZA,项目名称:gst-plugins-good,代码行数:101,代码来源:gstdv1394src.c
示例13: register_plugin
static gboolean
register_plugin (GstPlugin * plugin, const gchar * vendor,
const gchar * filename)
{
GModule *module;
GstFrei0rPluginRegisterReturn ret = GST_FREI0R_PLUGIN_REGISTER_RETURN_FAILED;
GstFrei0rFuncTable ftable = { NULL, };
gint i;
f0r_plugin_info_t info = { NULL, };
f0r_instance_t *instance = NULL;
GST_DEBUG ("Registering plugin '%s'", filename);
module = g_module_open (filename, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
if (!module) {
GST_WARNING ("Failed to load plugin");
return FALSE;
}
if (!g_module_symbol (module, "f0r_init", (gpointer *) & ftable.init)) {
GST_INFO ("No frei0r plugin");
g_module_close (module);
return FALSE;
}
if (!g_module_symbol (module, "f0r_deinit", (gpointer *) & ftable.deinit) ||
!g_module_symbol (module, "f0r_construct",
(gpointer *) & ftable.construct)
|| !g_module_symbol (module, "f0r_destruct",
(gpointer *) & ftable.destruct)
|| !g_module_symbol (module, "f0r_get_plugin_info",
(gpointer *) & ftable.get_plugin_info)
|| !g_module_symbol (module, "f0r_get_param_info",
(gpointer *) & ftable.get_param_info)
|| !g_module_symbol (module, "f0r_set_param_value",
(gpointer *) & ftable.set_param_value)
|| !g_module_symbol (module, "f0r_get_param_value",
(gpointer *) & ftable.get_param_value))
goto invalid_frei0r_plugin;
/* One of these must exist */
g_module_symbol (module, "f0r_update", (gpointer *) & ftable.update);
g_module_symbol (module, "f0r_update2", (gpointer *) & ftable.update2);
if (!ftable.init ()) {
GST_WARNING ("Failed to initialize plugin");
g_module_close (module);
return FALSE;
}
if (!ftable.update && !ftable.update2)
goto invalid_frei0r_plugin;
ftable.get_plugin_info (&info);
if (info.frei0r_version > 1) {
GST_WARNING ("Unsupported frei0r version %d", info.frei0r_version);
ftable.deinit ();
g_module_close (module);
return FALSE;
}
if (info.color_model > F0R_COLOR_MODEL_PACKED32) {
GST_WARNING ("Unsupported color model %d", info.color_model);
ftable.deinit ();
g_module_close (module);
return FALSE;
}
for (i = 0; i < info.num_params; i++) {
f0r_param_info_t pinfo = { NULL, };
ftable.get_param_info (&pinfo, i);
if (pinfo.type > F0R_PARAM_STRING) {
GST_WARNING ("Unsupported parameter type %d", pinfo.type);
ftable.deinit ();
g_module_close (module);
return FALSE;
}
}
instance = ftable.construct (640, 480);
if (!instance) {
GST_WARNING ("Failed to instanciate plugin '%s'", info.name);
ftable.deinit ();
g_module_close (module);
return FALSE;
}
ftable.destruct (instance);
switch (info.plugin_type) {
case F0R_PLUGIN_TYPE_FILTER:
ret = gst_frei0r_filter_register (plugin, vendor, &info, &ftable);
break;
case F0R_PLUGIN_TYPE_SOURCE:
ret = gst_frei0r_src_register (plugin, vendor, &info, &ftable);
break;
case F0R_PLUGIN_TYPE_MIXER2:
case F0R_PLUGIN_TYPE_MIXER3:
ret = gst_frei0r_mixer_register (plugin, vendor, &info, &ftable);
//.........这里部分代码省略.........
开发者ID:Haifen,项目名称:gst-plugins-bad,代码行数:101,代码来源:gstfrei0r.c
示例14: thread_pool_func
static void thread_pool_func (gpointer data, gpointer user_data)
{
HTTPServer *http_server = (HTTPServer *)user_data;
RequestData **request_data_pointer = data;
RequestData *request_data = *request_data_pointer;
gint ret;
GstClockTime cb_ret;
GST_DEBUG ("EVENT %d, status %d, sock %d", request_data->events, request_data->status, request_data->sock);
g_mutex_lock (&(request_data->events_mutex));
if (request_data->events & (EPOLLHUP | EPOLLERR)) {
request_data->status = HTTP_FINISH;
request_data->events = 0;
} else if (request_data->events & EPOLLOUT) {
if ((request_data->status == HTTP_IDLE) || (request_data->status == HTTP_BLOCK)) {
request_data->status = HTTP_CONTINUE;
}
request_data->events ^= EPOLLOUT;
} else if (request_data->events & EPOLLIN) {
if ((request_data->status == HTTP_IDLE) || (request_data->status == HTTP_BLOCK)) {
/* in normal play status */
ret = read_request (request_data);
if (ret < 0) {
request_data->status = HTTP_FINISH;
} else {
GST_DEBUG ("Unexpected request arrived, ignore.");
request_data->status = HTTP_CONTINUE;
}
}
/* HTTP_REQUEST status */
request_data->events ^= EPOLLIN;
} else if ((request_data->status == HTTP_IDLE) || (request_data->status == HTTP_BLOCK)) {
/* no event, popup from idle queue or block queue */
request_data->status = HTTP_CONTINUE;
} else {
GST_WARNING ("warning!!! unprocessed event, sock %d status %d events %d", request_data->sock, request_data->status, request_data->events);
}
g_mutex_unlock (&(request_data->events_mutex));
if (request_data->status == HTTP_REQUEST) {
ret = read_request (request_data);
if (ret < 0) {
request_data_release (http_server, request_data_pointer);
return;
}
ret = parse_request (request_data);
if (ret == 0) {
/* parse complete, call back user function */
request_data->events ^= EPOLLIN;
invoke_user_callback (http_server, request_data_pointer);
} else if (ret == 1) {
/* need read more data */
g_mutex_lock (&(http_server->block_queue_mutex));
g_queue_push_head (http_server->block_queue, request_data_pointer);
g_mutex_unlock (&(http_server->block_queue_mutex));
return;
} else if (ret == 2) {
/* Not Implemented */
GST_WARNING ("Not Implemented, return is %d, sock is %d", ret, request_data->sock);
gchar *buf = g_strdup_printf (http_501, PACKAGE_NAME, PACKAGE_VERSION);
if (httpserver_write (request_data->sock, buf, strlen (buf)) != strlen (buf)) {
GST_ERROR ("write sock %d error.", request_data->sock);
}
g_free (buf);
request_data_release (http_server, request_data_pointer);
} else {
/* Bad Request */
GST_WARNING ("Bad request, return is %d, sock is %d", ret, request_data->sock);
gchar *buf = g_strdup_printf (http_400, PACKAGE_NAME, PACKAGE_VERSION);
if (httpserver_write (request_data->sock, buf, strlen (buf)) != strlen (buf)) {
GST_ERROR ("write sock %d error.", request_data->sock);
}
g_free (buf);
request_data_release (http_server, request_data_pointer);
}
} else if (request_data->status == HTTP_CONTINUE) {
invoke_user_callback (http_server, request_data_pointer);
} else if (request_data->status == HTTP_FINISH) { // FIXME: how about if have continue request in idle queue??
cb_ret = http_server->user_callback (request_data, http_server->user_data);
GST_DEBUG ("request finish %d callback return %lu, send %lu", request_data->sock, cb_ret, request_data->bytes_send);
if (cb_ret == 0) {
g_mutex_lock (&(http_server->idle_queue_mutex));
g_tree_remove (http_server->idle_queue, &(request_data->wakeup_time));
g_mutex_unlock (&(http_server->idle_queue_mutex));
request_data_release (http_server, request_data_pointer);
}
}
}
开发者ID:i4tv,项目名称:gstreamill,代码行数:99,代码来源:httpserver.c
示例15: gst_udpsrc_create
//.........这里部分代码省略.........
NULL, NULL, &flags, udpsrc->cancellable, &err);
if (G_UNLIKELY (res < 0)) {
/* EHOSTUNREACH for a UDP socket means that a packet sent with udpsink
* generated a "port unreachable" ICMP response. We ignore that and try
* again. */
if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_HOST_UNREACHABLE)) {
g_clear_error (&err);
goto retry;
}
goto receive_error;
}
/* remember maximum packet size */
if (res > udpsrc->max_size)
udpsrc->max_size = res;
outbuf = gst_buffer_new ();
/* append first memory chunk to buffer */
gst_buffer_append_memory (outbuf, udpsrc->mem);
/* if the packet didn't fit into the first chunk, add second one as well */
if (res > udpsrc->map.size) {
gst_buffer_append_memory (outbuf, udpsrc->mem_max);
gst_memory_unmap (udpsrc->mem_max, &udpsrc->map_max);
udpsrc->vec[1].buffer = NULL;
udpsrc->vec[1].size = 0;
udpsrc->mem_max = NULL;
}
/* make sure we allocate a new chunk next time (we do this only here because
* we look at map.size to see if the second memory chunk is needed above) */
gst_memory_unmap (udpsrc->mem, &udpsrc->map);
udpsrc->vec[0].buff
|
请发表评论