~ubuntu-branches/ubuntu/precise/gst-plugins-base0.10/precise-updates

« back to all changes in this revision

Viewing changes to gst/playback/gstsubtitleoverlay.c

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2011-12-12 12:40:13 UTC
  • mfrom: (36.1.15 experimental)
  • Revision ID: package-import@ubuntu.com-20111212124013-onyadfb150d8c5dk
Tags: 0.10.35.2-2
* debian/libgstreamer-plugins-base.install:
  + Add license translations file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
#include <gst/video/video.h>
46
46
#include <string.h>
47
47
 
 
48
#include "gst/glib-compat-private.h"
 
49
 
48
50
GST_DEBUG_CATEGORY_STATIC (subtitle_overlay_debug);
49
51
#define GST_CAT_DEFAULT subtitle_overlay_debug
50
52
 
178
180
  "subtitle_sink", "subtitle"
179
181
};
180
182
 
 
183
static inline gboolean
 
184
_is_raw_video (GstStructure * s)
 
185
{
 
186
  const gchar *name;
 
187
 
 
188
  name = gst_structure_get_name (s);
 
189
 
 
190
  if (g_str_has_prefix (name, "video/x-raw-"))
 
191
    return TRUE;
 
192
  return FALSE;
 
193
}
 
194
 
 
195
static gboolean
 
196
_is_video_pad (GstPad * pad, gboolean * hw_accelerated)
 
197
{
 
198
  GstPad *peer = gst_pad_get_peer (pad);
 
199
  GstCaps *caps;
 
200
  gboolean ret;
 
201
  const gchar *name;
 
202
 
 
203
  if (peer) {
 
204
    caps = gst_pad_get_negotiated_caps (peer);
 
205
    if (!caps) {
 
206
      caps = gst_pad_get_caps_reffed (peer);
 
207
    }
 
208
    gst_object_unref (peer);
 
209
  } else {
 
210
    caps = gst_pad_get_caps_reffed (pad);
 
211
  }
 
212
 
 
213
 
 
214
  name = gst_structure_get_name (gst_caps_get_structure (caps, 0));
 
215
  if (g_str_has_prefix (name, "video/x-raw-")) {
 
216
    ret = TRUE;
 
217
    if (hw_accelerated)
 
218
      *hw_accelerated = FALSE;
 
219
 
 
220
  } else if (g_str_has_prefix (name, "video/x-surface")) {
 
221
    ret = TRUE;
 
222
    if (hw_accelerated)
 
223
      *hw_accelerated = TRUE;
 
224
  } else {
 
225
 
 
226
    ret = FALSE;
 
227
    if (hw_accelerated)
 
228
      *hw_accelerated = FALSE;
 
229
  }
 
230
 
 
231
  gst_caps_unref (caps);
 
232
 
 
233
  return ret;
 
234
}
 
235
 
181
236
static GstCaps *
182
237
_get_sub_caps (GstElementFactory * factory)
183
238
{
262
317
  templ_caps = _get_sub_caps (factory);
263
318
 
264
319
  if (is_renderer && have_video_sink && templ_caps) {
265
 
    GstCaps *tmp;
266
 
 
267
320
    GST_DEBUG ("Found renderer element %s (%s) with caps %" GST_PTR_FORMAT,
268
321
        gst_element_factory_get_longname (factory),
269
322
        gst_plugin_feature_get_name (feature), templ_caps);
270
 
    tmp = gst_caps_union (*subcaps, templ_caps);
271
 
    gst_caps_unref (templ_caps);
272
 
    gst_caps_replace (subcaps, tmp);
273
 
    gst_caps_unref (tmp);
 
323
    gst_caps_merge (*subcaps, templ_caps);
274
324
    return TRUE;
275
325
  } else if (!is_renderer && !have_video_sink && templ_caps) {
276
 
    GstCaps *tmp;
277
 
 
278
326
    GST_DEBUG ("Found parser element %s (%s) with caps %" GST_PTR_FORMAT,
279
327
        gst_element_factory_get_longname (factory),
280
328
        gst_plugin_feature_get_name (feature), templ_caps);
281
 
    tmp = gst_caps_union (*subcaps, templ_caps);
282
 
    gst_caps_unref (templ_caps);
283
 
    gst_caps_replace (subcaps, tmp);
284
 
    gst_caps_unref (tmp);
 
329
    gst_caps_merge (*subcaps, templ_caps);
285
330
    return TRUE;
286
331
  } else {
287
332
    if (templ_caps)
347
392
}
348
393
 
349
394
static gboolean
350
 
_filter_factories_for_caps (GstElementFactory * factory, const GstCaps * caps)
 
395
check_factory_for_caps (GstElementFactory * factory, const GstCaps * caps)
351
396
{
352
397
  GstCaps *fcaps = _get_sub_caps (factory);
353
398
  gboolean ret = (fcaps) ? gst_caps_can_intersect (fcaps, caps) : FALSE;
360
405
  return ret;
361
406
}
362
407
 
 
408
static GList *
 
409
gst_subtitle_overlay_get_factories_for_caps (const GList * list,
 
410
    const GstCaps * caps)
 
411
{
 
412
  const GList *walk = list;
 
413
  GList *result = NULL;
 
414
 
 
415
  while (walk) {
 
416
    GstElementFactory *factory = walk->data;
 
417
 
 
418
    walk = g_list_next (walk);
 
419
 
 
420
    if (check_factory_for_caps (factory, caps)) {
 
421
      result = g_list_prepend (result, factory);
 
422
    }
 
423
  }
 
424
 
 
425
  return result;
 
426
}
 
427
 
363
428
static gint
364
429
_sort_by_ranks (GstPluginFeature * f1, GstPluginFeature * f2)
365
430
{
606
671
out:
607
672
  /* Unblock pads */
608
673
  gst_pad_set_blocked_async_full (self->video_block_pad, FALSE,
609
 
      _pad_blocked_cb, gst_object_ref (self),
610
 
      (GDestroyNotify) gst_object_unref);
 
674
      _pad_blocked_cb, self, NULL);
611
675
 
612
676
  if (self->subtitle_sink_blocked)
613
677
    gst_pad_set_blocked_async_full (self->subtitle_block_pad, FALSE,
614
 
        _pad_blocked_cb, gst_object_ref (self),
615
 
        (GDestroyNotify) gst_object_unref);
 
678
        _pad_blocked_cb, self, NULL);
616
679
 
617
680
  return TRUE;
618
681
}
755
818
 
756
819
      /* Unblock pads */
757
820
      gst_pad_set_blocked_async_full (self->video_block_pad, FALSE,
758
 
          _pad_blocked_cb, gst_object_ref (self),
759
 
          (GDestroyNotify) gst_object_unref);
 
821
          _pad_blocked_cb, self, NULL);
760
822
 
761
823
      if (self->subtitle_sink_blocked)
762
824
        gst_pad_set_blocked_async_full (self->subtitle_block_pad, FALSE,
763
 
            _pad_blocked_cb, gst_object_ref (self),
764
 
            (GDestroyNotify) gst_object_unref);
 
825
            _pad_blocked_cb, self, NULL);
765
826
      goto out;
766
827
    } else if (target) {
767
828
      gst_object_unref (target);
771
832
  if (self->subtitle_sink_blocked && !self->video_sink_blocked) {
772
833
    GST_DEBUG_OBJECT (self, "Subtitle sink blocked but video not blocked");
773
834
    gst_pad_set_blocked_async_full (self->video_block_pad, TRUE,
774
 
        _pad_blocked_cb, gst_object_ref (self),
775
 
        (GDestroyNotify) gst_object_unref);
 
835
        _pad_blocked_cb, self, NULL);
776
836
    goto out;
777
837
  }
778
838
 
782
842
  g_mutex_lock (self->factories_lock);
783
843
  gst_subtitle_overlay_update_factory_list (self);
784
844
  if (subcaps) {
785
 
    factories = gst_filter_run (self->factories,
786
 
        (GstFilterFunc) _filter_factories_for_caps, FALSE, subcaps);
 
845
    factories =
 
846
        gst_subtitle_overlay_get_factories_for_caps (self->factories, subcaps);
787
847
    if (!factories) {
788
848
      GstMessage *msg;
789
849
 
810
870
 
811
871
  for (l = factories; l; l = l->next) {
812
872
    GstElementFactory *factory = l->data;
813
 
    gboolean is_renderer = _is_renderer (factory);
 
873
    gboolean is_video, is_hw, is_renderer = _is_renderer (factory);
814
874
    GstElement *element;
815
875
    GstPad *sink, *src;
816
876
 
841
901
 
842
902
    element = is_renderer ? self->renderer : self->parser;
843
903
 
 
904
    is_video = _is_video_pad (self->video_sinkpad, &is_hw);
844
905
    /* If this is a parser, create textoverlay and link video and the parser to it
845
906
     * Else link the renderer to the output colorspace */
846
907
    if (!is_renderer) {
918
979
      gst_object_unref (sink);
919
980
      gst_object_unref (src);
920
981
 
921
 
      if (G_UNLIKELY (!_create_element (self, &self->post_colorspace,
922
 
                  "ffmpegcolorspace", NULL, "post-colorspace", FALSE))) {
923
 
        continue;
924
 
      }
925
 
 
926
 
      src = gst_element_get_static_pad (overlay, "src");
927
 
      if (G_UNLIKELY (!src)) {
928
 
        GST_WARNING_OBJECT (self, "Can't get src pad from overlay");
929
 
        continue;
930
 
      }
931
 
 
932
 
      sink = gst_element_get_static_pad (self->post_colorspace, "sink");
933
 
      if (G_UNLIKELY (!sink)) {
934
 
        GST_WARNING_OBJECT (self, "Can't get sink pad from ffmpegcolorspace");
935
 
        gst_object_unref (src);
936
 
        continue;
937
 
      }
938
 
 
939
 
      if (G_UNLIKELY (gst_pad_link (src, sink) != GST_PAD_LINK_OK)) {
940
 
        GST_WARNING_OBJECT (self, "Can't link overlay with ffmpegcolorspace");
941
 
        gst_object_unref (src);
942
 
        gst_object_unref (sink);
943
 
        continue;
944
 
      }
945
 
      gst_object_unref (src);
946
 
      gst_object_unref (sink);
947
 
 
948
 
      if (G_UNLIKELY (!_create_element (self, &self->pre_colorspace,
949
 
                  "ffmpegcolorspace", NULL, "pre-colorspace", FALSE))) {
950
 
        continue;
951
 
      }
952
 
 
953
 
      sink = gst_element_get_static_pad (overlay, "video_sink");
954
 
      if (G_UNLIKELY (!sink)) {
955
 
        GST_WARNING_OBJECT (self, "Can't get video sink from textoverlay");
956
 
        continue;
957
 
      }
958
 
 
959
 
      src = gst_element_get_static_pad (self->pre_colorspace, "src");
960
 
      if (G_UNLIKELY (!src)) {
961
 
        GST_WARNING_OBJECT (self, "Can't get srcpad from ffmpegcolorspace");
962
 
        gst_object_unref (sink);
963
 
        continue;
964
 
      }
965
 
 
966
 
      if (G_UNLIKELY (gst_pad_link (src, sink) != GST_PAD_LINK_OK)) {
967
 
        GST_WARNING_OBJECT (self, "Can't link ffmpegcolorspace to textoverlay");
968
 
        gst_object_unref (src);
969
 
        gst_object_unref (sink);
970
 
        continue;
971
 
      }
972
 
      gst_object_unref (src);
973
 
      gst_object_unref (sink);
974
 
 
975
 
      /* Set src ghostpad target */
976
 
      src = gst_element_get_static_pad (self->post_colorspace, "src");
977
 
      if (G_UNLIKELY (!src)) {
978
 
        GST_WARNING_OBJECT (self, "Can't get src pad from ffmpegcolorspace");
979
 
        continue;
980
 
      }
981
 
 
982
 
      if (G_UNLIKELY (!gst_ghost_pad_set_target (GST_GHOST_PAD_CAST
983
 
                  (self->srcpad), src))) {
984
 
        GST_WARNING_OBJECT (self, "Can't set srcpad target");
985
 
        gst_object_unref (src);
986
 
        continue;
987
 
      }
988
 
      gst_object_unref (src);
 
982
      /* If we are working with video/x-surface, we do not add
 
983
       * colorspace conversion elements */
 
984
      if (is_video && !is_hw) {
 
985
        if (G_UNLIKELY (!_create_element (self, &self->post_colorspace,
 
986
                    COLORSPACE, NULL, "post-colorspace", FALSE))) {
 
987
          continue;
 
988
        }
 
989
 
 
990
        src = gst_element_get_static_pad (overlay, "src");
 
991
        if (G_UNLIKELY (!src)) {
 
992
          GST_WARNING_OBJECT (self, "Can't get src pad from overlay");
 
993
          continue;
 
994
        }
 
995
 
 
996
        sink = gst_element_get_static_pad (self->post_colorspace, "sink");
 
997
        if (G_UNLIKELY (!sink)) {
 
998
          GST_WARNING_OBJECT (self, "Can't get sink pad from " COLORSPACE);
 
999
          gst_object_unref (src);
 
1000
          continue;
 
1001
        }
 
1002
 
 
1003
        if (G_UNLIKELY (gst_pad_link (src, sink) != GST_PAD_LINK_OK)) {
 
1004
          GST_WARNING_OBJECT (self, "Can't link overlay with " COLORSPACE);
 
1005
          gst_object_unref (src);
 
1006
          gst_object_unref (sink);
 
1007
          continue;
 
1008
        }
 
1009
        gst_object_unref (src);
 
1010
        gst_object_unref (sink);
 
1011
 
 
1012
        if (G_UNLIKELY (!_create_element (self, &self->pre_colorspace,
 
1013
                    "identity", NULL, "pre-colorspace", FALSE))) {
 
1014
          continue;
 
1015
        }
 
1016
 
 
1017
        sink = gst_element_get_static_pad (overlay, "video_sink");
 
1018
        if (G_UNLIKELY (!sink)) {
 
1019
          GST_WARNING_OBJECT (self, "Can't get video sink from textoverlay");
 
1020
          continue;
 
1021
        }
 
1022
 
 
1023
        src = gst_element_get_static_pad (self->pre_colorspace, "src");
 
1024
        if (G_UNLIKELY (!src)) {
 
1025
          GST_WARNING_OBJECT (self, "Can't get srcpad from " COLORSPACE);
 
1026
          gst_object_unref (sink);
 
1027
          continue;
 
1028
        }
 
1029
 
 
1030
        if (G_UNLIKELY (gst_pad_link (src, sink) != GST_PAD_LINK_OK)) {
 
1031
          GST_WARNING_OBJECT (self, "Can't link " COLORSPACE " to textoverlay");
 
1032
          gst_object_unref (src);
 
1033
          gst_object_unref (sink);
 
1034
          continue;
 
1035
        }
 
1036
        gst_object_unref (src);
 
1037
        gst_object_unref (sink);
 
1038
 
 
1039
        /* Set src ghostpad target */
 
1040
        src = gst_element_get_static_pad (self->post_colorspace, "src");
 
1041
        if (G_UNLIKELY (!src)) {
 
1042
          GST_WARNING_OBJECT (self, "Can't get src pad from " COLORSPACE);
 
1043
          continue;
 
1044
        }
 
1045
 
 
1046
        if (G_UNLIKELY (!gst_ghost_pad_set_target (GST_GHOST_PAD_CAST
 
1047
                    (self->srcpad), src))) {
 
1048
          GST_WARNING_OBJECT (self, "Can't set srcpad target");
 
1049
          gst_object_unref (src);
 
1050
          continue;
 
1051
        }
 
1052
        gst_object_unref (src);
 
1053
      } else if (is_hw) {
 
1054
        GST_DEBUG_OBJECT (self,
 
1055
            "Is Hardware, not adding colorspace converters, ");
 
1056
        /* Set src ghostpad target */
 
1057
        src = gst_element_get_static_pad (self->overlay, "src");
 
1058
        if (G_UNLIKELY (!src)) {
 
1059
          GST_WARNING_OBJECT (self, "Can't get src pad from textoverlay");
 
1060
          continue;
 
1061
        }
 
1062
 
 
1063
        if (G_UNLIKELY (!gst_ghost_pad_set_target (GST_GHOST_PAD_CAST
 
1064
                    (self->srcpad), src))) {
 
1065
          GST_WARNING_OBJECT (self, "Can't set srcpad target");
 
1066
          gst_object_unref (src);
 
1067
          continue;
 
1068
        }
 
1069
        gst_object_unref (src);
 
1070
      }
989
1071
 
990
1072
      /* Send segments to the parser/overlay if necessary. These are not sent
991
1073
       * outside this element because of the proxy pad event function */
992
1074
      if (self->video_segment.format != GST_FORMAT_UNDEFINED) {
993
1075
        GstEvent *event1, *event2;
994
1076
 
995
 
        sink = gst_element_get_static_pad (self->pre_colorspace, "sink");
996
 
        if (G_UNLIKELY (!sink)) {
997
 
          GST_WARNING_OBJECT (self, "Can't get sink pad from ffmpegcolorspace");
998
 
          continue;
 
1077
        if (is_video) {
 
1078
          sink = gst_element_get_static_pad (self->pre_colorspace, "sink");
 
1079
          if (G_UNLIKELY (!sink)) {
 
1080
            GST_WARNING_OBJECT (self, "Can't get sink pad from " COLORSPACE);
 
1081
            continue;
 
1082
          }
 
1083
        } else {
 
1084
          sink = gst_element_get_static_pad (self->overlay, "video_sink");
 
1085
          if (G_UNLIKELY (!sink)) {
 
1086
            GST_WARNING_OBJECT (self, "Can't get sink pad from textoverlay");
 
1087
            continue;
 
1088
          }
999
1089
        }
1000
1090
 
1001
1091
        _generate_update_newsegment_event (&self->video_segment, &event1,
1036
1126
      }
1037
1127
 
1038
1128
      /* Set the sink ghostpad targets */
1039
 
      sink = gst_element_get_static_pad (self->pre_colorspace, "sink");
1040
 
      if (G_UNLIKELY (!sink)) {
1041
 
        GST_WARNING_OBJECT (self, "Can't get sink pad from ffmpegcolorspace");
1042
 
        continue;
 
1129
      if (is_video && !is_hw) {
 
1130
        sink = gst_element_get_static_pad (self->pre_colorspace, "sink");
 
1131
        if (G_UNLIKELY (!sink)) {
 
1132
          GST_WARNING_OBJECT (self, "Can't get sink pad from " COLORSPACE);
 
1133
          continue;
 
1134
        }
 
1135
      } else if (is_video && is_hw) {
 
1136
        GST_DEBUG_OBJECT (self, "Setting ghostpad to overlay video sink");
 
1137
        sink = gst_element_get_static_pad (self->overlay, "video_sink");
 
1138
        if (G_UNLIKELY (!sink)) {
 
1139
          GST_WARNING_OBJECT (self, "Can't get sink pad from overlay");
 
1140
          continue;
 
1141
        }
1043
1142
      }
1044
1143
 
1045
1144
      if (G_UNLIKELY (!gst_ghost_pad_set_target (GST_GHOST_PAD_CAST
1086
1185
          g_object_set (self->renderer, "font-desc", self->font_desc, NULL);
1087
1186
      }
1088
1187
 
1089
 
      /* First link everything internally */
1090
 
      if (G_UNLIKELY (!_create_element (self, &self->post_colorspace,
1091
 
                  "ffmpegcolorspace", NULL, "post-colorspace", FALSE))) {
1092
 
        continue;
1093
 
      }
1094
 
 
1095
 
      src = gst_element_get_static_pad (element, "src");
1096
 
      if (G_UNLIKELY (!src)) {
1097
 
        GST_WARNING_OBJECT (self, "Can't get src pad from renderer");
1098
 
        continue;
1099
 
      }
1100
 
 
1101
 
      sink = gst_element_get_static_pad (self->post_colorspace, "sink");
1102
 
      if (G_UNLIKELY (!sink)) {
1103
 
        GST_WARNING_OBJECT (self, "Can't get sink pad from ffmpegcolorspace");
1104
 
        gst_object_unref (src);
1105
 
        continue;
1106
 
      }
1107
 
 
1108
 
      if (G_UNLIKELY (gst_pad_link (src, sink) != GST_PAD_LINK_OK)) {
1109
 
        GST_WARNING_OBJECT (self, "Can't link renderer with ffmpegcolorspace");
1110
 
        gst_object_unref (src);
1111
 
        gst_object_unref (sink);
1112
 
        continue;
1113
 
      }
1114
 
      gst_object_unref (src);
1115
 
      gst_object_unref (sink);
1116
 
 
1117
 
      if (G_UNLIKELY (!_create_element (self, &self->pre_colorspace,
1118
 
                  "ffmpegcolorspace", NULL, "pre-colorspace", FALSE))) {
1119
 
        continue;
1120
 
      }
1121
 
 
1122
 
      sink = _get_video_pad (element);
1123
 
      if (G_UNLIKELY (!sink)) {
1124
 
        GST_WARNING_OBJECT (self, "Can't get video sink from renderer");
1125
 
        continue;
1126
 
      }
1127
 
 
1128
 
      src = gst_element_get_static_pad (self->pre_colorspace, "src");
1129
 
      if (G_UNLIKELY (!src)) {
1130
 
        GST_WARNING_OBJECT (self, "Can't get srcpad from ffmpegcolorspace");
1131
 
        gst_object_unref (sink);
1132
 
        continue;
1133
 
      }
1134
 
 
1135
 
      if (G_UNLIKELY (gst_pad_link (src, sink) != GST_PAD_LINK_OK)) {
1136
 
        GST_WARNING_OBJECT (self, "Can't link ffmpegcolorspace to renderer");
1137
 
        gst_object_unref (src);
1138
 
        gst_object_unref (sink);
1139
 
        continue;
1140
 
      }
1141
 
      gst_object_unref (src);
1142
 
      gst_object_unref (sink);
1143
 
 
1144
 
      /* Set src ghostpad target */
1145
 
      src = gst_element_get_static_pad (self->post_colorspace, "src");
1146
 
      if (G_UNLIKELY (!src)) {
1147
 
        GST_WARNING_OBJECT (self, "Can't get src pad from ffmpegcolorspace");
1148
 
        continue;
 
1188
      if (is_video) {
 
1189
        gboolean render_is_hw;
 
1190
 
 
1191
        /* First check that renderer also supports the video format */
 
1192
        sink = _get_video_pad (element);
 
1193
        if (G_UNLIKELY (!sink)) {
 
1194
          GST_WARNING_OBJECT (self, "Can't get video sink from renderer");
 
1195
          continue;
 
1196
        }
 
1197
 
 
1198
        if (is_video != _is_video_pad (sink, &render_is_hw) ||
 
1199
            is_hw != render_is_hw) {
 
1200
          GST_DEBUG_OBJECT (self, "Renderer doesn't support %s video",
 
1201
              is_hw ? "surface" : "raw");
 
1202
          gst_object_unref (sink);
 
1203
          continue;
 
1204
        }
 
1205
        gst_object_unref (sink);
 
1206
 
 
1207
        if (!is_hw) {
 
1208
          /* First link everything internally */
 
1209
          if (G_UNLIKELY (!_create_element (self, &self->post_colorspace,
 
1210
                      COLORSPACE, NULL, "post-colorspace", FALSE))) {
 
1211
            continue;
 
1212
          }
 
1213
          src = gst_element_get_static_pad (element, "src");
 
1214
          if (G_UNLIKELY (!src)) {
 
1215
            GST_WARNING_OBJECT (self, "Can't get src pad from renderer");
 
1216
            continue;
 
1217
          }
 
1218
 
 
1219
          sink = gst_element_get_static_pad (self->post_colorspace, "sink");
 
1220
          if (G_UNLIKELY (!sink)) {
 
1221
            GST_WARNING_OBJECT (self, "Can't get sink pad from " COLORSPACE);
 
1222
            gst_object_unref (src);
 
1223
            continue;
 
1224
          }
 
1225
 
 
1226
          if (G_UNLIKELY (gst_pad_link (src, sink) != GST_PAD_LINK_OK)) {
 
1227
            GST_WARNING_OBJECT (self, "Can't link renderer with " COLORSPACE);
 
1228
            gst_object_unref (src);
 
1229
            gst_object_unref (sink);
 
1230
            continue;
 
1231
          }
 
1232
          gst_object_unref (src);
 
1233
          gst_object_unref (sink);
 
1234
 
 
1235
          if (G_UNLIKELY (!_create_element (self, &self->pre_colorspace,
 
1236
                      COLORSPACE, NULL, "pre-colorspace", FALSE))) {
 
1237
            continue;
 
1238
          }
 
1239
 
 
1240
          sink = _get_video_pad (element);
 
1241
          if (G_UNLIKELY (!sink)) {
 
1242
            GST_WARNING_OBJECT (self, "Can't get video sink from renderer");
 
1243
            continue;
 
1244
          }
 
1245
 
 
1246
          src = gst_element_get_static_pad (self->pre_colorspace, "src");
 
1247
          if (G_UNLIKELY (!src)) {
 
1248
            GST_WARNING_OBJECT (self, "Can't get srcpad from " COLORSPACE);
 
1249
            gst_object_unref (sink);
 
1250
            continue;
 
1251
          }
 
1252
 
 
1253
          if (G_UNLIKELY (gst_pad_link (src, sink) != GST_PAD_LINK_OK)) {
 
1254
            GST_WARNING_OBJECT (self, "Can't link " COLORSPACE " to renderer");
 
1255
            gst_object_unref (src);
 
1256
            gst_object_unref (sink);
 
1257
            continue;
 
1258
          }
 
1259
          gst_object_unref (src);
 
1260
          gst_object_unref (sink);
 
1261
 
 
1262
          /* Set src ghostpad target */
 
1263
          src = gst_element_get_static_pad (self->post_colorspace, "src");
 
1264
          if (G_UNLIKELY (!src)) {
 
1265
            GST_WARNING_OBJECT (self, "Can't get src pad from " COLORSPACE);
 
1266
            continue;
 
1267
          }
 
1268
        } else {
 
1269
          /* Set src ghostpad target in the harware accelerated case */
 
1270
 
 
1271
          src = gst_element_get_static_pad (self->renderer, "src");
 
1272
          if (G_UNLIKELY (!src)) {
 
1273
            GST_WARNING_OBJECT (self, "Can't get src pad from renderer");
 
1274
            continue;
 
1275
          }
 
1276
        }
 
1277
      } else {                  /* No video pad */
 
1278
        GstCaps *allowed_caps, *video_caps = NULL;
 
1279
        GstPad *video_peer;
 
1280
        gboolean can_intersect = FALSE;
 
1281
 
 
1282
        video_peer = gst_pad_get_peer (self->video_sinkpad);
 
1283
        if (video_peer) {
 
1284
          video_caps = gst_pad_get_negotiated_caps (video_peer);
 
1285
          if (!video_caps) {
 
1286
            video_caps = gst_pad_get_caps_reffed (video_peer);
 
1287
          }
 
1288
          gst_object_unref (video_peer);
 
1289
        }
 
1290
 
 
1291
        sink = _get_video_pad (element);
 
1292
        if (G_UNLIKELY (!sink)) {
 
1293
          GST_WARNING_OBJECT (self, "Can't get video sink from renderer");
 
1294
          continue;
 
1295
        }
 
1296
        allowed_caps = gst_pad_get_caps_reffed (sink);
 
1297
        gst_object_unref (sink);
 
1298
 
 
1299
        if (allowed_caps && video_caps)
 
1300
          can_intersect = gst_caps_can_intersect (allowed_caps, video_caps);
 
1301
 
 
1302
        if (allowed_caps)
 
1303
          gst_caps_unref (allowed_caps);
 
1304
 
 
1305
        if (video_caps)
 
1306
          gst_caps_unref (video_caps);
 
1307
 
 
1308
        if (G_UNLIKELY (!can_intersect)) {
 
1309
          GST_WARNING_OBJECT (self, "Renderer with custom caps is not "
 
1310
              "compatible with video stream");
 
1311
          continue;
 
1312
        }
 
1313
 
 
1314
        src = gst_element_get_static_pad (element, "src");
 
1315
        if (G_UNLIKELY (!src)) {
 
1316
          GST_WARNING_OBJECT (self, "Can't get src pad from renderer");
 
1317
          continue;
 
1318
        }
1149
1319
      }
1150
1320
 
1151
1321
      if (G_UNLIKELY (!gst_ghost_pad_set_target (GST_GHOST_PAD_CAST
1163
1333
 
1164
1334
        sink = gst_element_get_static_pad (self->pre_colorspace, "sink");
1165
1335
        if (G_UNLIKELY (!sink)) {
1166
 
          GST_WARNING_OBJECT (self, "Can't get sink pad from ffmpegcolorspace");
 
1336
          GST_WARNING_OBJECT (self, "Can't get sink pad from " COLORSPACE);
1167
1337
          continue;
1168
1338
        }
1169
1339
 
1203
1373
      }
1204
1374
 
1205
1375
      /* Set the sink ghostpad targets */
1206
 
      sink = gst_element_get_static_pad (self->pre_colorspace, "sink");
1207
 
      if (G_UNLIKELY (!sink)) {
1208
 
        GST_WARNING_OBJECT (self, "Can't get sink pad from ffmpegcolorspace");
1209
 
        continue;
 
1376
      if (self->pre_colorspace) {
 
1377
        sink = gst_element_get_static_pad (self->pre_colorspace, "sink");
 
1378
        if (G_UNLIKELY (!sink)) {
 
1379
          GST_WARNING_OBJECT (self, "Can't get sink pad from " COLORSPACE);
 
1380
          continue;
 
1381
        }
 
1382
      } else {
 
1383
        sink = _get_video_pad (element);
 
1384
        if (G_UNLIKELY (!sink)) {
 
1385
          GST_WARNING_OBJECT (self, "Can't get sink pad from %" GST_PTR_FORMAT,
 
1386
              element);
 
1387
          continue;
 
1388
        }
1210
1389
      }
1211
1390
 
1212
1391
      if (G_UNLIKELY (!gst_ghost_pad_set_target (GST_GHOST_PAD_CAST
1244
1423
  } else {
1245
1424
    GST_DEBUG_OBJECT (self, "Everything worked, unblocking pads");
1246
1425
    gst_pad_set_blocked_async_full (self->video_block_pad, FALSE,
1247
 
        _pad_blocked_cb, gst_object_ref (self),
1248
 
        (GDestroyNotify) gst_object_unref);
 
1426
        _pad_blocked_cb, self, NULL);
1249
1427
    gst_pad_set_blocked_async_full (self->subtitle_block_pad, FALSE,
1250
 
        _pad_blocked_cb, gst_object_ref (self),
1251
 
        (GDestroyNotify) gst_object_unref);
 
1428
        _pad_blocked_cb, self, NULL);
1252
1429
    do_async_done (self);
1253
1430
  }
1254
1431
 
1278
1455
      GST_SUBTITLE_OVERLAY_LOCK (self);
1279
1456
      /* Set the internal pads to blocking */
1280
1457
      gst_pad_set_blocked_async_full (self->video_block_pad, TRUE,
1281
 
          _pad_blocked_cb, gst_object_ref (self),
1282
 
          (GDestroyNotify) gst_object_unref);
 
1458
          _pad_blocked_cb, self, NULL);
1283
1459
      gst_pad_set_blocked_async_full (self->subtitle_block_pad, TRUE,
1284
 
          _pad_blocked_cb, gst_object_ref (self),
1285
 
          (GDestroyNotify) gst_object_unref);
 
1460
          _pad_blocked_cb, self, NULL);
1286
1461
      GST_SUBTITLE_OVERLAY_UNLOCK (self);
1287
1462
      break;
1288
1463
    case GST_STATE_CHANGE_READY_TO_PAUSED:
1349
1524
      if (self->video_block_pad) {
1350
1525
        pad = self->video_block_pad;
1351
1526
        gst_pad_set_blocked_async_full (pad, FALSE, _pad_blocked_cb,
1352
 
            gst_object_ref (self), (GDestroyNotify) gst_object_unref);
 
1527
            self, NULL);
1353
1528
      }
1354
1529
 
1355
1530
      if (self->subtitle_block_pad) {
1356
1531
        pad = self->subtitle_block_pad;
1357
1532
        gst_pad_set_blocked_async_full (pad, FALSE, _pad_blocked_cb,
1358
 
            gst_object_ref (self), (GDestroyNotify) gst_object_unref);
 
1533
            self, NULL);
1359
1534
      }
1360
1535
 
1361
1536
      /* Remove elements */
1415
1590
      self->subtitle_error = TRUE;
1416
1591
 
1417
1592
      gst_pad_set_blocked_async_full (self->subtitle_block_pad, TRUE,
1418
 
          _pad_blocked_cb, gst_object_ref (self),
1419
 
          (GDestroyNotify) gst_object_unref);
 
1593
          _pad_blocked_cb, self, NULL);
1420
1594
 
1421
1595
      gst_pad_set_blocked_async_full (self->video_block_pad, TRUE,
1422
 
          _pad_blocked_cb, gst_object_ref (self),
1423
 
          (GDestroyNotify) gst_object_unref);
 
1596
          _pad_blocked_cb, self, NULL);
1424
1597
      GST_SUBTITLE_OVERLAY_UNLOCK (self);
1425
1598
    }
1426
1599
  }
1476
1649
          g_object_set (self->renderer, self->silent_property, silent, NULL);
1477
1650
      } else {
1478
1651
        gst_pad_set_blocked_async_full (self->subtitle_block_pad, TRUE,
1479
 
            _pad_blocked_cb, gst_object_ref (self),
1480
 
            (GDestroyNotify) gst_object_unref);
 
1652
            _pad_blocked_cb, self, NULL);
1481
1653
 
1482
1654
        gst_pad_set_blocked_async_full (self->video_block_pad, TRUE,
1483
 
            _pad_blocked_cb, gst_object_ref (self),
1484
 
            (GDestroyNotify) gst_object_unref);
 
1655
            _pad_blocked_cb, self, NULL);
1485
1656
      }
1486
1657
      GST_SUBTITLE_OVERLAY_UNLOCK (self);
1487
1658
      break;
1517
1688
{
1518
1689
  GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
1519
1690
 
1520
 
  gst_element_class_add_pad_template (gstelement_class,
1521
 
      gst_static_pad_template_get (&srctemplate));
 
1691
  gst_element_class_add_static_pad_template (gstelement_class, &srctemplate);
1522
1692
 
1523
 
  gst_element_class_add_pad_template (gstelement_class,
1524
 
      gst_static_pad_template_get (&video_sinktemplate));
1525
 
  gst_element_class_add_pad_template (gstelement_class,
1526
 
      gst_static_pad_template_get (&subtitle_sinktemplate));
 
1693
  gst_element_class_add_static_pad_template (gstelement_class,
 
1694
      &video_sinktemplate);
 
1695
  gst_element_class_add_static_pad_template (gstelement_class,
 
1696
      &subtitle_sinktemplate);
1527
1697
 
1528
1698
  gst_element_class_set_details_simple (gstelement_class, "Subtitle Overlay",
1529
1699
      "Video/Overlay/Subtitle",
1589
1759
    return GST_FLOW_ERROR;
1590
1760
  }
1591
1761
 
1592
 
  ret = self->src_proxy_chain (proxypad, buffer);
 
1762
  ret = gst_proxy_pad_chain_default (proxypad, buffer);
1593
1763
 
1594
1764
  if (IS_VIDEO_CHAIN_IGNORE_ERROR (ret)) {
1595
1765
    GST_ERROR_OBJECT (self, "Downstream chain error: %s",
1626
1796
    event = NULL;
1627
1797
    ret = TRUE;
1628
1798
  } else {
1629
 
    ret = self->src_proxy_event (proxypad, event);
 
1799
    ret = gst_proxy_pad_event_default (proxypad, event);
1630
1800
    event = NULL;
1631
1801
  }
1632
1802
 
1644
1814
gst_subtitle_overlay_video_sink_setcaps (GstPad * pad, GstCaps * caps)
1645
1815
{
1646
1816
  GstSubtitleOverlay *self = GST_SUBTITLE_OVERLAY (gst_pad_get_parent (pad));
 
1817
  GstPad *target;
1647
1818
  gboolean ret = TRUE;
1648
1819
  gint fps_n, fps_d;
1649
1820
 
1650
1821
  GST_DEBUG_OBJECT (pad, "Setting caps: %" GST_PTR_FORMAT, caps);
1651
1822
 
 
1823
  target = gst_ghost_pad_get_target (GST_GHOST_PAD_CAST (self->video_sinkpad));
 
1824
 
 
1825
  GST_SUBTITLE_OVERLAY_LOCK (self);
 
1826
 
 
1827
  if (!target || !gst_pad_accept_caps (target, caps)) {
 
1828
    GST_DEBUG_OBJECT (pad, "Target did not accept caps -- reconfiguring");
 
1829
 
 
1830
    gst_pad_set_blocked_async_full (self->subtitle_block_pad, TRUE,
 
1831
        _pad_blocked_cb, self, NULL);
 
1832
 
 
1833
    gst_pad_set_blocked_async_full (self->video_block_pad, TRUE,
 
1834
        _pad_blocked_cb, self, NULL);
 
1835
  }
 
1836
 
1652
1837
  if (!gst_video_parse_caps_framerate (caps, &fps_n, &fps_d)) {
1653
1838
    GST_ERROR_OBJECT (pad, "Failed to parse framerate from caps");
1654
1839
    ret = FALSE;
 
1840
    GST_SUBTITLE_OVERLAY_UNLOCK (self);
1655
1841
    goto out;
1656
1842
  }
1657
1843
 
1658
 
  GST_SUBTITLE_OVERLAY_LOCK (self);
1659
1844
  if (self->fps_n != fps_n || self->fps_d != fps_d) {
1660
1845
    GST_DEBUG_OBJECT (self, "New video fps: %d/%d", fps_n, fps_d);
1661
1846
    self->fps_n = fps_n;
1664
1849
  }
1665
1850
  GST_SUBTITLE_OVERLAY_UNLOCK (self);
1666
1851
 
1667
 
  ret = self->video_sink_setcaps (pad, caps);
 
1852
  ret = gst_ghost_pad_setcaps_default (pad, caps);
1668
1853
 
1669
1854
out:
 
1855
  if (target)
 
1856
    gst_object_unref (target);
1670
1857
  gst_object_unref (self);
1671
1858
  return ret;
1672
1859
}
1684
1871
    self->fps_n = self->fps_d = 0;
1685
1872
  }
1686
1873
 
1687
 
  ret = self->video_sink_event (pad, gst_event_ref (event));
 
1874
  ret = gst_proxy_pad_event_default (pad, gst_event_ref (event));
1688
1875
 
1689
1876
  if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) {
1690
1877
    gboolean update;
1700
1887
    if (format != GST_FORMAT_TIME) {
1701
1888
      GST_ERROR_OBJECT (pad, "Newsegment event in non-time format: %s",
1702
1889
          gst_format_get_name (format));
1703
 
      gst_object_unref (event);
 
1890
      gst_event_unref (event);
1704
1891
      gst_object_unref (self);
1705
1892
      return FALSE;
1706
1893
    }
1722
1909
gst_subtitle_overlay_video_sink_chain (GstPad * pad, GstBuffer * buffer)
1723
1910
{
1724
1911
  GstSubtitleOverlay *self = GST_SUBTITLE_OVERLAY (GST_PAD_PARENT (pad));
1725
 
  GstFlowReturn ret = self->video_sink_chain (pad, buffer);
 
1912
  GstFlowReturn ret = gst_proxy_pad_chain_default (pad, buffer);
1726
1913
 
1727
1914
  if (G_UNLIKELY (self->downstream_chain_error) || self->passthrough_identity) {
1728
1915
    return ret;
1732
1919
    GST_SUBTITLE_OVERLAY_LOCK (self);
1733
1920
    self->subtitle_error = TRUE;
1734
1921
    gst_pad_set_blocked_async_full (self->subtitle_block_pad, TRUE,
1735
 
        _pad_blocked_cb, gst_object_ref (self),
1736
 
        (GDestroyNotify) gst_object_unref);
 
1922
        _pad_blocked_cb, self, NULL);
1737
1923
 
1738
1924
    gst_pad_set_blocked_async_full (self->video_block_pad, TRUE,
1739
 
        _pad_blocked_cb, gst_object_ref (self),
1740
 
        (GDestroyNotify) gst_object_unref);
 
1925
        _pad_blocked_cb, self, NULL);
1741
1926
    GST_SUBTITLE_OVERLAY_UNLOCK (self);
1742
1927
 
1743
1928
    return GST_FLOW_OK;
1755
1940
    gst_buffer_unref (buffer);
1756
1941
    return GST_FLOW_OK;
1757
1942
  } else {
1758
 
    GstFlowReturn ret = self->subtitle_sink_chain (pad, buffer);
 
1943
    GstFlowReturn ret = gst_proxy_pad_chain_default (pad, buffer);
1759
1944
 
1760
1945
    if (IS_SUBTITLE_CHAIN_IGNORE_ERROR (ret)) {
1761
1946
      GST_DEBUG_OBJECT (self, "Subtitle chain error: %s",
1763
1948
      GST_SUBTITLE_OVERLAY_LOCK (self);
1764
1949
      self->subtitle_error = TRUE;
1765
1950
      gst_pad_set_blocked_async_full (self->subtitle_block_pad, TRUE,
1766
 
          _pad_blocked_cb, gst_object_ref (self),
1767
 
          (GDestroyNotify) gst_object_unref);
 
1951
          _pad_blocked_cb, self, NULL);
1768
1952
 
1769
1953
      gst_pad_set_blocked_async_full (self->video_block_pad, TRUE,
1770
 
          _pad_blocked_cb, gst_object_ref (self),
1771
 
          (GDestroyNotify) gst_object_unref);
 
1954
          _pad_blocked_cb, self, NULL);
1772
1955
      GST_SUBTITLE_OVERLAY_UNLOCK (self);
1773
1956
 
1774
1957
      return GST_FLOW_OK;
1802
1985
gst_subtitle_overlay_subtitle_sink_acceptcaps (GstPad * pad, GstCaps * caps)
1803
1986
{
1804
1987
  GstCaps *othercaps = gst_subtitle_overlay_subtitle_sink_getcaps (pad);
1805
 
  gboolean ret = gst_caps_can_intersect (caps, othercaps);
 
1988
  gboolean ret = gst_caps_is_subset (caps, othercaps);
1806
1989
 
1807
1990
  gst_caps_unref (othercaps);
1808
1991
 
1826
2009
 
1827
2010
  if (target && gst_pad_accept_caps (target, caps)) {
1828
2011
    GST_DEBUG_OBJECT (pad, "Target accepts caps");
1829
 
    ret = self->subtitle_sink_setcaps (pad, caps);
 
2012
    ret = gst_ghost_pad_setcaps_default (pad, caps);
1830
2013
    GST_SUBTITLE_OVERLAY_UNLOCK (self);
1831
2014
    goto out;
1832
2015
  }
1836
2019
  self->subtitle_error = FALSE;
1837
2020
 
1838
2021
  gst_pad_set_blocked_async_full (self->subtitle_block_pad, TRUE,
1839
 
      _pad_blocked_cb, gst_object_ref (self),
1840
 
      (GDestroyNotify) gst_object_unref);
 
2022
      _pad_blocked_cb, self, NULL);
1841
2023
 
1842
2024
  gst_pad_set_blocked_async_full (self->video_block_pad, TRUE,
1843
 
      _pad_blocked_cb, gst_object_ref (self),
1844
 
      (GDestroyNotify) gst_object_unref);
 
2025
      _pad_blocked_cb, self, NULL);
1845
2026
  GST_SUBTITLE_OVERLAY_UNLOCK (self);
1846
2027
 
1847
2028
out:
1877
2058
    self->subtitle_error = FALSE;
1878
2059
 
1879
2060
    gst_pad_set_blocked_async_full (self->subtitle_block_pad, TRUE,
1880
 
        _pad_blocked_cb, gst_object_ref (self),
1881
 
        (GDestroyNotify) gst_object_unref);
 
2061
        _pad_blocked_cb, self, NULL);
1882
2062
 
1883
2063
    gst_pad_set_blocked_async_full (self->video_block_pad, TRUE,
1884
 
        _pad_blocked_cb, gst_object_ref (self),
1885
 
        (GDestroyNotify) gst_object_unref);
 
2064
        _pad_blocked_cb, self, NULL);
1886
2065
    GST_SUBTITLE_OVERLAY_UNLOCK (self);
1887
2066
    gst_caps_unref (caps);
1888
2067
  }
1889
2068
 
1890
 
  ret = self->subtitle_sink_link (pad, peer);
 
2069
  ret = gst_ghost_pad_link_default (pad, peer);
1891
2070
 
1892
2071
  gst_object_unref (self);
1893
2072
  return ret;
1906
2085
  GST_DEBUG_OBJECT (pad, "Pad unlinking");
1907
2086
  gst_caps_replace (&self->subcaps, NULL);
1908
2087
 
1909
 
  self->subtitle_sink_unlink (pad);
 
2088
  gst_ghost_pad_unlink_default (pad);
1910
2089
 
1911
2090
  GST_SUBTITLE_OVERLAY_LOCK (self);
1912
2091
  self->subtitle_error = FALSE;
1913
2092
 
1914
2093
  if (self->subtitle_block_pad)
1915
2094
    gst_pad_set_blocked_async_full (self->subtitle_block_pad, TRUE,
1916
 
        _pad_blocked_cb, gst_object_ref (self),
1917
 
        (GDestroyNotify) gst_object_unref);
 
2095
        _pad_blocked_cb, self, NULL);
1918
2096
 
1919
2097
  if (self->video_block_pad)
1920
2098
    gst_pad_set_blocked_async_full (self->video_block_pad, TRUE,
1921
 
        _pad_blocked_cb, gst_object_ref (self),
1922
 
        (GDestroyNotify) gst_object_unref);
 
2099
        _pad_blocked_cb, self, NULL);
1923
2100
  GST_SUBTITLE_OVERLAY_UNLOCK (self);
1924
2101
 
1925
2102
  gst_object_unref (self);
1942
2119
    self->subtitle_error = FALSE;
1943
2120
    if (self->subtitle_block_pad)
1944
2121
      gst_pad_set_blocked_async_full (self->subtitle_block_pad, TRUE,
1945
 
          _pad_blocked_cb, gst_object_ref (self),
1946
 
          (GDestroyNotify) gst_object_unref);
 
2122
          _pad_blocked_cb, self, NULL);
1947
2123
    if (self->video_block_pad)
1948
2124
      gst_pad_set_blocked_async_full (self->video_block_pad, TRUE,
1949
 
          _pad_blocked_cb, gst_object_ref (self),
1950
 
          (GDestroyNotify) gst_object_unref);
 
2125
          _pad_blocked_cb, self, NULL);
1951
2126
    GST_SUBTITLE_OVERLAY_UNLOCK (self);
1952
2127
 
1953
2128
    gst_event_unref (event);
1993
2168
      break;
1994
2169
  }
1995
2170
 
1996
 
  ret = self->subtitle_sink_event (pad, gst_event_ref (event));
 
2171
  ret = gst_proxy_pad_event_default (pad, gst_event_ref (event));
1997
2172
 
1998
2173
  if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) {
1999
2174
    gboolean update;
2031
2206
    GstSubtitleOverlayClass * klass)
2032
2207
{
2033
2208
  GstPadTemplate *templ;
2034
 
  GstIterator *it;
2035
2209
  GstPad *proxypad = NULL;
2036
2210
 
2037
2211
  self->lock = g_mutex_new ();
2039
2213
 
2040
2214
  templ = gst_static_pad_template_get (&srctemplate);
2041
2215
  self->srcpad = gst_ghost_pad_new_no_target_from_template ("src", templ);
2042
 
  it = gst_pad_iterate_internal_links (self->srcpad);
2043
 
  if (G_UNLIKELY (!it
2044
 
          || gst_iterator_next (it, (gpointer) & proxypad) != GST_ITERATOR_OK
2045
 
          || proxypad == NULL)) {
2046
 
    GST_ERROR_OBJECT (self, "Failed to get proxypad of srcpad");
2047
 
  } else {
2048
 
    self->src_proxy_event = GST_PAD_EVENTFUNC (proxypad);
2049
 
    gst_pad_set_event_function (proxypad,
2050
 
        GST_DEBUG_FUNCPTR (gst_subtitle_overlay_src_proxy_event));
2051
 
    self->src_proxy_chain = GST_PAD_CHAINFUNC (proxypad);
2052
 
    gst_pad_set_chain_function (proxypad,
2053
 
        GST_DEBUG_FUNCPTR (gst_subtitle_overlay_src_proxy_chain));
2054
 
    gst_object_unref (proxypad);
2055
 
  }
2056
 
  if (it)
2057
 
    gst_iterator_free (it);
 
2216
  gst_object_unref (templ);
 
2217
 
 
2218
  proxypad =
 
2219
      GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD (self->srcpad)));
 
2220
  gst_pad_set_event_function (proxypad,
 
2221
      GST_DEBUG_FUNCPTR (gst_subtitle_overlay_src_proxy_event));
 
2222
  gst_pad_set_chain_function (proxypad,
 
2223
      GST_DEBUG_FUNCPTR (gst_subtitle_overlay_src_proxy_chain));
 
2224
  gst_object_unref (proxypad);
2058
2225
 
2059
2226
  gst_element_add_pad (GST_ELEMENT_CAST (self), self->srcpad);
2060
2227
 
2061
2228
  templ = gst_static_pad_template_get (&video_sinktemplate);
2062
2229
  self->video_sinkpad =
2063
2230
      gst_ghost_pad_new_no_target_from_template ("video_sink", templ);
2064
 
  self->video_sink_event = GST_PAD_EVENTFUNC (self->video_sinkpad);
 
2231
  gst_object_unref (templ);
2065
2232
  gst_pad_set_event_function (self->video_sinkpad,
2066
2233
      GST_DEBUG_FUNCPTR (gst_subtitle_overlay_video_sink_event));
2067
 
  self->video_sink_setcaps = GST_PAD_SETCAPSFUNC (self->video_sinkpad);
2068
2234
  gst_pad_set_setcaps_function (self->video_sinkpad,
2069
2235
      GST_DEBUG_FUNCPTR (gst_subtitle_overlay_video_sink_setcaps));
2070
 
  self->video_sink_chain = GST_PAD_CHAINFUNC (self->video_sinkpad);
2071
2236
  gst_pad_set_chain_function (self->video_sinkpad,
2072
2237
      GST_DEBUG_FUNCPTR (gst_subtitle_overlay_video_sink_chain));
2073
2238
 
2074
 
  proxypad = NULL;
2075
 
  it = gst_pad_iterate_internal_links (self->video_sinkpad);
2076
 
  if (G_UNLIKELY (!it
2077
 
          || gst_iterator_next (it, (gpointer) & proxypad) != GST_ITERATOR_OK
2078
 
          || proxypad == NULL)) {
2079
 
    GST_ERROR_OBJECT (self,
2080
 
        "Failed to get internally linked pad from video sinkpad");
2081
 
  }
2082
 
  if (it)
2083
 
    gst_iterator_free (it);
 
2239
  proxypad =
 
2240
      GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD
 
2241
          (self->video_sinkpad)));
2084
2242
  self->video_block_pad = proxypad;
 
2243
  gst_object_unref (proxypad);
2085
2244
  gst_element_add_pad (GST_ELEMENT_CAST (self), self->video_sinkpad);
2086
2245
 
2087
2246
  templ = gst_static_pad_template_get (&subtitle_sinktemplate);
2088
2247
  self->subtitle_sinkpad =
2089
2248
      gst_ghost_pad_new_no_target_from_template ("subtitle_sink", templ);
2090
 
  self->subtitle_sink_link = GST_PAD_LINKFUNC (self->subtitle_sinkpad);
 
2249
  gst_object_unref (templ);
2091
2250
  gst_pad_set_link_function (self->subtitle_sinkpad,
2092
2251
      GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_link));
2093
 
  self->subtitle_sink_unlink = GST_PAD_UNLINKFUNC (self->subtitle_sinkpad);
2094
2252
  gst_pad_set_unlink_function (self->subtitle_sinkpad,
2095
2253
      GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_unlink));
2096
 
  self->subtitle_sink_event = GST_PAD_EVENTFUNC (self->subtitle_sinkpad);
2097
2254
  gst_pad_set_event_function (self->subtitle_sinkpad,
2098
2255
      GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_event));
2099
 
  self->subtitle_sink_setcaps = GST_PAD_SETCAPSFUNC (self->subtitle_sinkpad);
2100
2256
  gst_pad_set_setcaps_function (self->subtitle_sinkpad,
2101
2257
      GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_setcaps));
2102
 
  self->subtitle_sink_chain = GST_PAD_CHAINFUNC (self->subtitle_sinkpad);
2103
2258
  gst_pad_set_chain_function (self->subtitle_sinkpad,
2104
2259
      GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_chain));
2105
2260
  gst_pad_set_getcaps_function (self->subtitle_sinkpad,
2108
2263
      GST_DEBUG_FUNCPTR (gst_subtitle_overlay_subtitle_sink_acceptcaps));
2109
2264
  gst_pad_set_bufferalloc_function (self->subtitle_sinkpad, NULL);
2110
2265
 
2111
 
  proxypad = NULL;
2112
 
  it = gst_pad_iterate_internal_links (self->subtitle_sinkpad);
2113
 
  if (G_UNLIKELY (!it
2114
 
          || gst_iterator_next (it, (gpointer) & proxypad) != GST_ITERATOR_OK
2115
 
          || proxypad == NULL)) {
2116
 
    GST_ERROR_OBJECT (self,
2117
 
        "Failed to get internally linked pad from subtitle sinkpad");
2118
 
  }
2119
 
  if (it)
2120
 
    gst_iterator_free (it);
 
2266
  proxypad =
 
2267
      GST_PAD_CAST (gst_proxy_pad_get_internal (GST_PROXY_PAD
 
2268
          (self->subtitle_sinkpad)));
2121
2269
  self->subtitle_block_pad = proxypad;
 
2270
  gst_object_unref (proxypad);
2122
2271
 
2123
2272
  gst_element_add_pad (GST_ELEMENT_CAST (self), self->subtitle_sinkpad);
2124
2273