~ubuntu-branches/ubuntu/precise/gst0.10-python/precise

« back to all changes in this revision

Viewing changes to gst/gstelement.override

Tags: upstream-0.10.8
Import upstream version 0.10.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
        if (!PyArg_ParseTuple(args, "s:GstElement.get_pad_template", &name))
38
38
                return NULL;
39
39
 
 
40
        pyg_begin_allow_threads;
40
41
        tmpl = gst_element_class_get_pad_template
41
42
            (GST_ELEMENT_GET_CLASS (self->obj), name);
 
43
        pyg_end_allow_threads;
42
44
 
43
45
        if (tmpl) {
44
46
                ret = pygobject_new (G_OBJECT (tmpl));
137
139
 
138
140
        i = 2;
139
141
        while (1) {
140
 
 
141
 
                if (!gst_element_link(GST_ELEMENT(element->obj),
142
 
                                      GST_ELEMENT(element2->obj)))
 
142
                gboolean res;
 
143
 
 
144
                pyg_begin_allow_threads;
 
145
                res = gst_element_link(GST_ELEMENT(element->obj),
 
146
                                      GST_ELEMENT(element2->obj));
 
147
                pyg_end_allow_threads;
 
148
 
 
149
                if (!res) 
143
150
                {
144
151
                    PyErr_Format(PyGstExc_LinkError,
145
152
                                 "failed to link %s with %s",
186
193
        return NULL;
187
194
    }
188
195
 
 
196
    pyg_begin_allow_threads;
189
197
    ret = gst_element_link_filtered(GST_ELEMENT(self->obj), GST_ELEMENT(dest->obj), caps);
 
198
    pyg_end_allow_threads;
 
199
 
190
200
    if (caps && caps_is_copy)
191
201
        gst_caps_unref (caps);
192
202
    if (!ret) {
246
256
    if (!pad_name_from_object (srcpad, &srcpadname) ||
247
257
        !pad_name_from_object (destpad, &destpadname))
248
258
        return NULL;
 
259
 
 
260
    pyg_begin_allow_threads;
249
261
    ret = gst_element_link_pads(GST_ELEMENT(self->obj), srcpadname,
250
262
                                GST_ELEMENT(dest->obj), destpadname);
 
263
    pyg_end_allow_threads;
251
264
    if (!ret) {
252
265
        PyErr_SetString(PyGstExc_LinkError, "link failed");
253
266
        return NULL;
281
294
        PyErr_SetString(PyExc_TypeError, "filtercaps should be a GstCaps");
282
295
        return NULL;
283
296
    }
 
297
    pyg_begin_allow_threads;
284
298
    ret = gst_element_link_pads_filtered(GST_ELEMENT(self->obj), srcpadname,
285
299
                                         GST_ELEMENT(dest->obj), destpadname,
286
300
                                         filtercaps);
 
301
    pyg_end_allow_threads;
287
302
    if (!ret) {
288
303
        PyErr_SetString(PyGstExc_LinkError, "link failed");
289
304
        return NULL;
323
338
 
324
339
        i = 2;
325
340
        while (1) {
 
341
                pyg_begin_allow_threads;
326
342
                gst_element_unlink(GST_ELEMENT(element->obj), GST_ELEMENT(element2->obj));
 
343
                pyg_end_allow_threads;
327
344
 
328
345
                if (i >= len)
329
346
                        break;
358
375
    /* The pipeline unrefs the event, but we want to keep the ownership */
359
376
    gst_event_ref(event);
360
377
    
 
378
    pyg_begin_allow_threads;
361
379
    ret = gst_element_send_event(GST_ELEMENT(self->obj), event);
 
380
    pyg_end_allow_threads;
 
381
 
362
382
    return PyBool_FromLong(ret);
363
 
 
364
383
}
365
384
%%
366
385
override gst_element_query_position args
370
389
    gint64      cur;
371
390
    gint        format;
372
391
    PyObject    *pformat;
 
392
    gboolean    res;
373
393
 
374
394
    pformat = (PyObject*)PyTuple_GetItem(args, 0);
375
395
    if (pyg_enum_get_value (GST_TYPE_FORMAT, pformat, &format)) {
377
397
        return NULL;
378
398
    }
379
399
 
380
 
    if (!(gst_element_query_position(GST_ELEMENT (self->obj), (GstFormat*) &format, &cur))) {
 
400
    pyg_begin_allow_threads;
 
401
    res = gst_element_query_position(GST_ELEMENT (self->obj), (GstFormat*) &format, &cur);
 
402
    pyg_end_allow_threads;
 
403
 
 
404
    if (!res) {
381
405
        PyErr_Format(PyGstExc_QueryError,
382
406
                     "query failed");
383
407
        return NULL;
394
418
    gint64      cur;
395
419
    gint        format;
396
420
    PyObject    *pformat;
 
421
    gboolean    res;
397
422
 
398
423
    pformat = (PyObject*)PyTuple_GetItem(args, 0);
399
424
    if (pyg_enum_get_value (GST_TYPE_FORMAT, pformat, &format)) {
401
426
        return NULL;
402
427
    }
403
428
 
404
 
    if (!(gst_element_query_duration(GST_ELEMENT (self->obj), (GstFormat*) &format, &cur))) {
 
429
    pyg_begin_allow_threads;
 
430
    res = gst_element_query_duration(GST_ELEMENT (self->obj), (GstFormat*) &format, &cur);
 
431
    pyg_end_allow_threads;
 
432
 
 
433
    if (!res) {
405
434
        PyErr_Format(PyGstExc_QueryError,
406
435
                     "query failed");
407
436
        return NULL;
419
448
    PyObject    *pfromformat, *pdestformat;
420
449
    GstFormat   srcformat, destformat;
421
450
    gint64      fromval, dstval;
 
451
    gboolean    res;
422
452
 
423
453
    /* Input : src_format, src_val, dst_format */
424
454
    /* Returns : dst_format, dst_val OR None */
437
467
        return NULL;
438
468
    }
439
469
 
440
 
    if (!(gst_element_query_convert (GST_ELEMENT(self->obj),
 
470
    pyg_begin_allow_threads;
 
471
    res = gst_element_query_convert (GST_ELEMENT(self->obj),
441
472
                                     srcformat, fromval,
442
 
                                     &destformat, &dstval))) {
 
473
                                     &destformat, &dstval);
 
474
    pyg_end_allow_threads;
 
475
 
 
476
    if (!res) {
443
477
        Py_INCREF(Py_None);
444
478
        return Py_None;
445
479
    }
446
 
    
 
480
 
447
481
    return Py_BuildValue("(OL)", 
448
482
                         pyg_enum_from_gtype(GST_TYPE_FORMAT, destformat),
449
483
                         dstval);                                            
458
492
    int         i;
459
493
    GstQueryType        *tab;
460
494
 
 
495
    pyg_begin_allow_threads;
461
496
    tab = (GstQueryType*) gst_element_get_query_types(GST_ELEMENT(self->obj));
 
497
    pyg_end_allow_threads;
462
498
    if (tab == NULL) {
463
499
        Py_INCREF(Py_None);
464
500
        return Py_None;
488
524
        GList *res = NULL;
489
525
        guint i;
490
526
    
 
527
        pyg_begin_allow_threads;
491
528
        res = gst_element_class_get_pad_template_list
492
529
            (GST_ELEMENT_GET_CLASS (self->obj));
 
530
        pyg_end_allow_threads;
493
531
 
494
532
        if (res) {
495
533
                i = g_list_length (res);
505
543
 
506
544
        return ret;
507
545
}
 
546
%%
 
547
override GstElement__proxy_do_request_new_pad
 
548
static GstPad*
 
549
_wrap_GstElement__proxy_do_request_new_pad(GstElement *self, GstPadTemplate*templ, const gchar*name)
 
550
{
 
551
    PyGILState_STATE __py_state;
 
552
    PyObject *py_self;
 
553
    PyObject *py_templ = NULL;
 
554
    PyObject *py_name;
 
555
    GstPad* retval;
 
556
    PyObject *py_retval;
 
557
    PyObject *py_args;
 
558
    PyObject *py_method;
 
559
    
 
560
    __py_state = pyg_gil_state_ensure();
 
561
    py_self = pygobject_new((GObject *) self);
 
562
    if (!py_self) {
 
563
        if (PyErr_Occurred())
 
564
            PyErr_Print();
 
565
        pyg_gil_state_release(__py_state);
 
566
        return NULL;
 
567
    }
 
568
    if (templ)
 
569
        py_templ = pygobject_new((GObject *) templ);
 
570
    else {
 
571
        Py_INCREF(Py_None);
 
572
        py_templ = Py_None;
 
573
    }
 
574
 
 
575
    if (name == NULL) {
 
576
            Py_INCREF(Py_None);
 
577
            py_name = Py_None;
 
578
    } else {
 
579
            py_name = PyString_FromString(name);
 
580
            if (!py_name) {
 
581
                    if (PyErr_Occurred())
 
582
                            PyErr_Print();
 
583
                    Py_DECREF(py_templ);
 
584
                    Py_DECREF(py_self);
 
585
                    pyg_gil_state_release(__py_state);
 
586
                    return NULL;
 
587
            }
 
588
    }
 
589
    
 
590
    py_args = PyTuple_New(2);
 
591
    PyTuple_SET_ITEM(py_args, 0, py_templ);
 
592
    PyTuple_SET_ITEM(py_args, 1, py_name);
 
593
    
 
594
    py_method = PyObject_GetAttrString(py_self, "do_request_new_pad");
 
595
    if (!py_method) {
 
596
        if (PyErr_Occurred())
 
597
            PyErr_Print();
 
598
        Py_DECREF(py_args);
 
599
        Py_DECREF(py_self);
 
600
        pyg_gil_state_release(__py_state);
 
601
        return NULL;
 
602
    }
 
603
    py_retval = PyObject_CallObject(py_method, py_args);
 
604
    if (!py_retval) {
 
605
        if (PyErr_Occurred())
 
606
            PyErr_Print();
 
607
        Py_DECREF(py_method);
 
608
        Py_DECREF(py_args);
 
609
        Py_DECREF(py_self);
 
610
        pyg_gil_state_release(__py_state);
 
611
        return NULL;
 
612
    }
 
613
    if (!PyObject_TypeCheck(py_retval, &PyGObject_Type)) {
 
614
        PyErr_SetString(PyExc_TypeError, "retval should be a GObject");
 
615
        PyErr_Print();
 
616
        Py_DECREF(py_retval);
 
617
        Py_DECREF(py_method);
 
618
        Py_DECREF(py_args);
 
619
        Py_DECREF(py_self);
 
620
        pyg_gil_state_release(__py_state);
 
621
        return NULL;
 
622
    }
 
623
    retval = (GstPad*) pygobject_get(py_retval);
 
624
    g_object_ref((GObject *) retval);
 
625
    
 
626
    
 
627
    Py_DECREF(py_retval);
 
628
    Py_DECREF(py_method);
 
629
    Py_DECREF(py_args);
 
630
    Py_DECREF(py_self);
 
631
    pyg_gil_state_release(__py_state);
 
632
    
 
633
    return retval;
 
634
}