~ubuntu-branches/ubuntu/trusty/gstreamer1.0/trusty

« back to all changes in this revision

Viewing changes to gst/gstpad.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2012-08-08 18:12:33 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120808181233-riejwxprfsxh1njl
Tags: 0.11.93-1
* New upstream release:
  + debian/libgstreamer.symbols:
    - Update symbols file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
808
808
  return gst_pad_activate_mode (pad, GST_PAD_MODE_PUSH, TRUE);
809
809
}
810
810
 
 
811
#ifndef GST_DISABLE_GST_DEBUG
 
812
static const gchar *
 
813
gst_pad_mode_get_name (GstPadMode mode)
 
814
{
 
815
  switch (mode) {
 
816
    case GST_PAD_MODE_NONE:
 
817
      return "none";
 
818
    case GST_PAD_MODE_PUSH:
 
819
      return "push";
 
820
    case GST_PAD_MODE_PULL:
 
821
      return "pull";
 
822
    default:
 
823
      break;
 
824
  }
 
825
  return "unknown";
 
826
}
 
827
#endif
 
828
 
811
829
static void
812
830
pre_activate (GstPad * pad, GstPadMode new_mode)
813
831
{
824
842
    case GST_PAD_MODE_PUSH:
825
843
    case GST_PAD_MODE_PULL:
826
844
      GST_OBJECT_LOCK (pad);
827
 
      GST_DEBUG_OBJECT (pad, "setting PAD_MODE %d, unset flushing", new_mode);
 
845
      GST_DEBUG_OBJECT (pad, "setting pad into %s mode, unset flushing",
 
846
          gst_pad_mode_get_name (new_mode));
828
847
      GST_PAD_UNSET_FLUSHING (pad);
829
848
      GST_PAD_MODE (pad) = new_mode;
830
849
      if (GST_PAD_IS_SINK (pad)) {
911
930
      GST_DEBUG_OBJECT (pad, "activating pad from none");
912
931
      ret = (GST_PAD_ACTIVATEFUNC (pad)) (pad, parent);
913
932
    } else {
914
 
      GST_DEBUG_OBJECT (pad, "pad was active in mode %d", old);
 
933
      GST_DEBUG_OBJECT (pad, "pad was active in %s mode",
 
934
          gst_pad_mode_get_name (old));
915
935
      ret = TRUE;
916
936
    }
917
937
  } else {
919
939
      GST_DEBUG_OBJECT (pad, "pad was inactive");
920
940
      ret = TRUE;
921
941
    } else {
922
 
      GST_DEBUG_OBJECT (pad, "deactivating pad from mode %d", old);
 
942
      GST_DEBUG_OBJECT (pad, "deactivating pad from %s mode",
 
943
          gst_pad_mode_get_name (old));
923
944
      ret = gst_pad_activate_mode (pad, old, FALSE);
924
945
    }
925
946
  }
929
950
  if (G_UNLIKELY (!ret))
930
951
    goto failed;
931
952
 
932
 
  if (!active) {
933
 
    GST_OBJECT_LOCK (pad);
934
 
    GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_NEED_RECONFIGURE);
935
 
    GST_OBJECT_UNLOCK (pad);
936
 
  }
937
953
  return ret;
938
954
 
939
955
  /* ERRORS */
994
1010
  if (old == new)
995
1011
    goto was_ok;
996
1012
 
997
 
  if (active && old != mode) {
 
1013
  if (active && old != mode && old != GST_PAD_MODE_NONE) {
998
1014
    /* pad was activate in the wrong direction, deactivate it
999
1015
     * and reactivate it in the requested mode */
1000
 
    GST_DEBUG_OBJECT (pad, "deactivating pad from mode %d", old);
 
1016
    GST_DEBUG_OBJECT (pad, "deactivating pad from %s mode",
 
1017
        gst_pad_mode_get_name (old));
 
1018
 
1001
1019
    if (G_UNLIKELY (!gst_pad_activate_mode (pad, old, FALSE)))
1002
1020
      goto deactivate_failed;
1003
1021
  }
1043
1061
 
1044
1062
  post_activate (pad, new);
1045
1063
 
1046
 
  GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "%s in mode %d",
1047
 
      active ? "activated" : "deactivated", mode);
 
1064
  GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "%s in %s mode",
 
1065
      active ? "activated" : "deactivated", gst_pad_mode_get_name (mode));
1048
1066
 
1049
1067
exit_success:
1050
1068
  res = TRUE;
 
1069
 
 
1070
  /* Clear sticky flags on deactivation */
 
1071
  if (!active) {
 
1072
    GST_OBJECT_LOCK (pad);
 
1073
    GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_NEED_RECONFIGURE);
 
1074
    GST_OBJECT_FLAG_UNSET (pad, GST_PAD_FLAG_EOS);
 
1075
    GST_OBJECT_UNLOCK (pad);
 
1076
  }
 
1077
 
1051
1078
exit:
1052
1079
  RELEASE_PARENT (parent);
1053
1080
 
1061
1088
  }
1062
1089
was_ok:
1063
1090
  {
1064
 
    GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "already %s in mode %d",
1065
 
        active ? "activated" : "deactivated", mode);
 
1091
    GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "already %s in %s mode",
 
1092
        active ? "activated" : "deactivated", gst_pad_mode_get_name (mode));
1066
1093
    goto exit_success;
1067
1094
  }
1068
1095
deactivate_failed:
1069
1096
  {
1070
1097
    GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad,
1071
 
        "failed to %s in switch to mode %d from mode %d",
1072
 
        (active ? "activate" : "deactivate"), mode, old);
 
1098
        "failed to %s in switch to %s mode from %s mode",
 
1099
        (active ? "activate" : "deactivate"), gst_pad_mode_get_name (mode),
 
1100
        gst_pad_mode_get_name (old));
1073
1101
    goto exit;
1074
1102
  }
1075
1103
peer_failed:
1090
1118
failure:
1091
1119
  {
1092
1120
    GST_OBJECT_LOCK (pad);
1093
 
    GST_CAT_INFO_OBJECT (GST_CAT_PADS, pad, "failed to %s in mode %d",
1094
 
        active ? "activate" : "deactivate", mode);
 
1121
    GST_CAT_INFO_OBJECT (GST_CAT_PADS, pad, "failed to %s in %s mode",
 
1122
        active ? "activate" : "deactivate", gst_pad_mode_get_name (mode));
1095
1123
    GST_PAD_SET_FLUSHING (pad);
1096
1124
    GST_PAD_MODE (pad) = old;
1097
1125
    GST_OBJECT_UNLOCK (pad);
1313
1341
 * Returns: TRUE if the pad is blocking.
1314
1342
 *
1315
1343
 * MT safe.
1316
 
 *
1317
 
 * Since: 0.10.11
1318
1344
 */
1319
1345
gboolean
1320
1346
gst_pad_is_blocking (GstPad * pad)
1375
1401
}
1376
1402
 
1377
1403
/**
 
1404
 * gst_pad_set_activate_function:
 
1405
 * @p: a #GstPad.
 
1406
 * @f: the #GstPadActivateFunction to set.
 
1407
 *
 
1408
 * Calls gst_pad_set_activate_function_full() with NULL for the user_data and
 
1409
 * notify.
 
1410
 */
 
1411
/**
1378
1412
 * gst_pad_set_activate_function_full:
1379
1413
 * @pad: a #GstPad.
1380
1414
 * @activate: the #GstPadActivateFunction to set.
1404
1438
}
1405
1439
 
1406
1440
/**
 
1441
 * gst_pad_set_activatemode_function:
 
1442
 * @p: a #GstPad.
 
1443
 * @f: the #GstPadActivateModeFunction to set.
 
1444
 *
 
1445
 * Calls gst_pad_set_activatemode_function_full() with NULL for the user_data and
 
1446
 * notify.
 
1447
 */
 
1448
/**
1407
1449
 * gst_pad_set_activatemode_function_full:
1408
1450
 * @pad: a #GstPad.
1409
1451
 * @activatemode: the #GstPadActivateModeFunction to set.
1431
1473
}
1432
1474
 
1433
1475
/**
 
1476
 * gst_pad_set_chain_function:
 
1477
 * @p: a sink #GstPad.
 
1478
 * @f: the #GstPadChainFunction to set.
 
1479
 *
 
1480
 * Calls gst_pad_set_chain_function_full() with NULL for the user_data and
 
1481
 * notify.
 
1482
 */
 
1483
/**
1434
1484
 * gst_pad_set_chain_function_full:
1435
1485
 * @pad: a sink #GstPad.
1436
1486
 * @chain: the #GstPadChainFunction to set.
1458
1508
}
1459
1509
 
1460
1510
/**
 
1511
 * gst_pad_set_chain_list_function:
 
1512
 * @p: a sink #GstPad.
 
1513
 * @f: the #GstPadChainListFunction to set.
 
1514
 *
 
1515
 * Calls gst_pad_set_chain_list_function_full() with NULL for the user_data and
 
1516
 * notify.
 
1517
 */
 
1518
/**
1461
1519
 * gst_pad_set_chain_list_function_full:
1462
1520
 * @pad: a sink #GstPad.
1463
1521
 * @chainlist: the #GstPadChainListFunction to set.
1467
1525
 * Sets the given chain list function for the pad. The chainlist function is
1468
1526
 * called to process a #GstBufferList input buffer list. See
1469
1527
 * #GstPadChainListFunction for more details.
1470
 
 *
1471
 
 * Since: 0.10.24
1472
1528
 */
1473
1529
void
1474
1530
gst_pad_set_chain_list_function_full (GstPad * pad,
1489
1545
}
1490
1546
 
1491
1547
/**
 
1548
 * gst_pad_set_getrange_function:
 
1549
 * @p: a source #GstPad.
 
1550
 * @f: the #GstPadGetRangeFunction to set.
 
1551
 *
 
1552
 * Calls gst_pad_set_getrange_function_full() with NULL for the user_data and
 
1553
 * notify.
 
1554
 */
 
1555
/**
1492
1556
 * gst_pad_set_getrange_function_full:
1493
1557
 * @pad: a source #GstPad.
1494
1558
 * @get: the #GstPadGetRangeFunction to set.
1517
1581
}
1518
1582
 
1519
1583
/**
 
1584
 * gst_pad_set_event_function:
 
1585
 * @p: a #GstPad of either direction.
 
1586
 * @f: the #GstPadEventFunction to set.
 
1587
 *
 
1588
 * Calls gst_pad_set_event_function_full() with NULL for the user_data and
 
1589
 * notify.
 
1590
 */
 
1591
/**
1520
1592
 * gst_pad_set_event_function_full:
1521
1593
 * @pad: a #GstPad of either direction.
1522
1594
 * @event: the #GstPadEventFunction to set.
1542
1614
}
1543
1615
 
1544
1616
/**
 
1617
 * gst_pad_set_query_function:
 
1618
 * @p: a #GstPad of either direction.
 
1619
 * @f: the #GstPadQueryFunction to set.
 
1620
 *
 
1621
 * Calls gst_pad_set_query_function_full() with NULL for the user_data and
 
1622
 * notify.
 
1623
 */
 
1624
/**
1545
1625
 * gst_pad_set_query_function_full:
1546
1626
 * @pad: a #GstPad of either direction.
1547
1627
 * @query: the #GstPadQueryFunction to set.
1567
1647
}
1568
1648
 
1569
1649
/**
 
1650
 * gst_pad_set_iterate_internal_links_function:
 
1651
 * @p: a #GstPad of either direction.
 
1652
 * @f: the #GstPadIterIntLinkFunction to set.
 
1653
 *
 
1654
 * Calls gst_pad_set_iterate_internal_links_function_full() with NULL
 
1655
 * for the user_data and notify.
 
1656
 */
 
1657
/**
1570
1658
 * gst_pad_set_iterate_internal_links_function_full:
1571
1659
 * @pad: a #GstPad of either direction.
1572
1660
 * @iterintlink: the #GstPadIterIntLinkFunction to set.
1574
1662
 * @notify: notify called when @iterintlink will not be used anymore.
1575
1663
 *
1576
1664
 * Sets the given internal link iterator function for the pad.
1577
 
 *
1578
 
 * Since: 0.10.21
1579
1665
 */
1580
1666
void
1581
1667
gst_pad_set_iterate_internal_links_function_full (GstPad * pad,
1595
1681
}
1596
1682
 
1597
1683
/**
 
1684
 * gst_pad_set_link_function:
 
1685
 * @p: a #GstPad.
 
1686
 * @f: the #GstPadLinkFunction to set.
 
1687
 *
 
1688
 * Calls gst_pad_set_link_function_full() with NULL
 
1689
 * for the user_data and notify.
 
1690
 */
 
1691
/**
1598
1692
 * gst_pad_set_link_function_full:
1599
1693
 * @pad: a #GstPad.
1600
1694
 * @link: the #GstPadLinkFunction to set.
1630
1724
}
1631
1725
 
1632
1726
/**
 
1727
 * gst_pad_set_unlink_function:
 
1728
 * @p: a #GstPad.
 
1729
 * @f: the #GstPadUnlinkFunction to set.
 
1730
 *
 
1731
 * Calls gst_pad_set_unlink_function_full() with NULL
 
1732
 * for the user_data and notify.
 
1733
 */
 
1734
/**
1633
1735
 * gst_pad_set_unlink_function_full:
1634
1736
 * @pad: a #GstPad.
1635
1737
 * @unlink: the #GstPadUnlinkFunction to set.
2029
2131
 *
2030
2132
 * Returns: A result code indicating if the connection worked or
2031
2133
 *          what went wrong.
2032
 
 *
2033
 
 * Since: 0.10.30
2034
2134
 */
2035
2135
GstPadLinkReturn
2036
2136
gst_pad_link_full (GstPad * srcpad, GstPad * sinkpad, GstPadLinkCheck flags)
2257
2357
}
2258
2358
 
2259
2359
/**
2260
 
 * gst_pad_set_caps:
2261
 
 * @pad: a  #GstPad to set the capabilities of.
2262
 
 * @caps: (transfer none): a #GstCaps to set.
2263
 
 *
2264
 
 * Sets the capabilities of this pad. The caps must be fixed. Any previous
2265
 
 * caps on the pad will be unreffed. This function refs the caps so you should
2266
 
 * unref if as soon as you don't need it anymore.
2267
 
 * It is possible to set NULL caps, which will make the pad unnegotiated
2268
 
 * again.
2269
 
 *
2270
 
 * Returns: TRUE if the caps could be set. FALSE if the caps were not fixed
2271
 
 * or bad parameters were provided to this function.
2272
 
 *
2273
 
 * MT safe.
2274
 
 */
2275
 
gboolean
2276
 
gst_pad_set_caps (GstPad * pad, GstCaps * caps)
2277
 
{
2278
 
  GstEvent *event;
2279
 
  gboolean res = TRUE;
2280
 
 
2281
 
  g_return_val_if_fail (GST_IS_PAD (pad), FALSE);
2282
 
  g_return_val_if_fail (caps != NULL && gst_caps_is_fixed (caps), FALSE);
2283
 
 
2284
 
  event = gst_event_new_caps (caps);
2285
 
 
2286
 
  if (GST_PAD_IS_SRC (pad))
2287
 
    res = gst_pad_push_event (pad, event);
2288
 
  else
2289
 
    res = gst_pad_send_event (pad, event);
2290
 
 
2291
 
  return res;
2292
 
}
2293
 
 
2294
 
/**
2295
2360
 * gst_pad_get_pad_template_caps:
2296
2361
 * @pad: a #GstPad to get the template capabilities from.
2297
2362
 *
2411
2476
 *
2412
2477
 * Returns: a #GstIterator of #GstPad, or NULL if @pad has no parent. Unref each
2413
2478
 * returned pad with gst_object_unref().
2414
 
 *
2415
 
 * Since: 0.10.21
2416
2479
 */
2417
2480
GstIterator *
2418
2481
gst_pad_iterate_internal_links_default (GstPad * pad, GstObject * parent)
2480
2543
 * Returns: (transfer full): a new #GstIterator of #GstPad or %NULL when the
2481
2544
 *     pad does not have an iterator function configured. Use
2482
2545
 *     gst_iterator_free() after usage.
2483
 
 *
2484
 
 * Since: 0.10.21
2485
2546
 */
2486
2547
GstIterator *
2487
2548
gst_pad_iterate_internal_links (GstPad * pad)
2514
2575
/**
2515
2576
 * gst_pad_forward:
2516
2577
 * @pad: a #GstPad
2517
 
 * @forward: a #GstPadForwardFunction
 
2578
 * @forward: (scope call): a #GstPadForwardFunction
2518
2579
 * @user_data: user data passed to @forward
2519
2580
 *
2520
2581
 * Calls @forward for all internally linked pads of @pad. This function deals with
2714
2775
  GstPadTemplate *templ;
2715
2776
  gboolean fixed_caps;
2716
2777
 
2717
 
  GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "get pad caps");
2718
 
 
2719
 
  gst_query_parse_caps (query, &filter);
 
2778
  GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "query caps %" GST_PTR_FORMAT,
 
2779
      query);
2720
2780
 
2721
2781
  /* first try to proxy if we must */
2722
2782
  if (GST_PAD_IS_PROXY_CAPS (pad)) {
2723
2783
    if ((gst_pad_proxy_query_caps (pad, query))) {
2724
 
      gst_query_parse_caps_result (query, &result);
2725
 
      goto filter_done;
 
2784
      goto done;
2726
2785
    }
2727
2786
  }
2728
2787
 
 
2788
  gst_query_parse_caps (query, &filter);
 
2789
 
2729
2790
  /* no proxy or it failed, do default handling */
2730
2791
  fixed_caps = GST_PAD_IS_FIXED_CAPS (pad);
2731
2792
 
2758
2819
filter_done_unlock:
2759
2820
  GST_OBJECT_UNLOCK (pad);
2760
2821
 
2761
 
filter_done:
2762
2822
  /* run the filter on the result */
2763
2823
  if (filter) {
2764
2824
    GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad,
2772
2832
        "using caps %p %" GST_PTR_FORMAT, result, result);
2773
2833
    result = gst_caps_ref (result);
2774
2834
  }
2775
 
 
2776
2835
  gst_query_set_caps_result (query, result);
2777
2836
  gst_caps_unref (result);
2778
2837
 
 
2838
done:
2779
2839
  return TRUE;
2780
2840
}
2781
2841
 
2790
2850
query_forward_func (GstPad * pad, QueryData * data)
2791
2851
{
2792
2852
  GST_LOG_OBJECT (pad, "query peer %p (%s) of %s:%s",
2793
 
      data->query, GST_EVENT_TYPE_NAME (data->query), GST_DEBUG_PAD_NAME (pad));
 
2853
      data->query, GST_QUERY_TYPE_NAME (data->query), GST_DEBUG_PAD_NAME (pad));
2794
2854
 
2795
2855
  data->result |= gst_pad_peer_query (pad, data->query);
2796
2856
 
2821
2881
 
2822
2882
  switch (GST_QUERY_TYPE (query)) {
2823
2883
    case GST_QUERY_SCHEDULING:
2824
 
      forward = FALSE;
 
2884
      forward = GST_PAD_IS_PROXY_SCHEDULING (pad);
2825
2885
      break;
2826
2886
    case GST_QUERY_ALLOCATION:
2827
2887
      forward = GST_PAD_IS_PROXY_ALLOCATION (pad);
3372
3432
 *
3373
3433
 * Returns: TRUE if the query could be performed. This function returns %FALSE
3374
3434
 * if @pad has no peer.
3375
 
 *
3376
 
 * Since: 0.10.15
3377
3435
 */
3378
3436
gboolean
3379
3437
gst_pad_peer_query (GstPad * pad, GstQuery * query)
3694
3752
 * MT safe.
3695
3753
 *
3696
3754
 * Returns: a #GstFlowReturn from the pad.
3697
 
 *
3698
 
 * Since: 0.10.24
3699
3755
 */
3700
3756
GstFlowReturn
3701
3757
gst_pad_chain_list (GstPad * pad, GstBufferList * list)
3871
3927
 * Returns: a #GstFlowReturn from the peer pad.
3872
3928
 *
3873
3929
 * MT safe.
3874
 
 *
3875
 
 * Since: 0.10.24
3876
3930
 */
3877
3931
GstFlowReturn
3878
3932
gst_pad_push_list (GstPad * pad, GstBufferList * list)
5025
5079
      thread, task);
5026
5080
}
5027
5081
 
5028
 
static GstTaskThreadCallbacks thr_callbacks = {
5029
 
  pad_enter_thread,
5030
 
  pad_leave_thread,
5031
 
};
5032
 
 
5033
5082
/**
5034
5083
 * gst_pad_start_task:
5035
5084
 * @pad: the #GstPad to start the task of
5036
5085
 * @func: the task function to call
5037
 
 * @data: data passed to the task function
 
5086
 * @user_data: user data passed to the task function
 
5087
 * @notify: called when @user_data is no longer referenced
5038
5088
 *
5039
 
 * Starts a task that repeatedly calls @func with @data. This function
 
5089
 * Starts a task that repeatedly calls @func with @user_data. This function
5040
5090
 * is mostly used in pad activation functions to start the dataflow.
5041
5091
 * The #GST_PAD_STREAM_LOCK of @pad will automatically be acquired
5042
5092
 * before @func is called.
5044
5094
 * Returns: a %TRUE if the task could be started.
5045
5095
 */
5046
5096
gboolean
5047
 
gst_pad_start_task (GstPad * pad, GstTaskFunction func, gpointer data)
 
5097
gst_pad_start_task (GstPad * pad, GstTaskFunction func, gpointer user_data,
 
5098
    GDestroyNotify notify)
5048
5099
{
5049
5100
  GstTask *task;
5050
5101
  gboolean res;
5057
5108
  GST_OBJECT_LOCK (pad);
5058
5109
  task = GST_PAD_TASK (pad);
5059
5110
  if (task == NULL) {
5060
 
    task = gst_task_new (func, data);
 
5111
    task = gst_task_new (func, user_data, notify);
5061
5112
    gst_task_set_lock (task, GST_PAD_GET_STREAM_LOCK (pad));
5062
 
    gst_task_set_thread_callbacks (task, &thr_callbacks, pad, NULL);
 
5113
    gst_task_set_enter_callback (task, pad_enter_thread, pad, NULL);
 
5114
    gst_task_set_leave_callback (task, pad_leave_thread, pad, NULL);
5063
5115
    GST_INFO_OBJECT (pad, "created task %p", task);
5064
5116
    GST_PAD_TASK (pad) = task;
5065
5117
    gst_object_ref (task);