gstreamer_core/tsrc/check/gst/gstbin/src/gstbin.c
changeset 8 4a7fac7dd34a
parent 0 0e761a78d257
child 9 2a0f36a70380
equal deleted inserted replaced
7:71e347f905f2 8:4a7fac7dd34a
    32 #include "std_log_result.h" 
    32 #include "std_log_result.h" 
    33 #define LOG_FILENAME_LINE __FILE__, __LINE__
    33 #define LOG_FILENAME_LINE __FILE__, __LINE__
    34 
    34 
    35 void create_xml(int result)
    35 void create_xml(int result)
    36 {
    36 {
       
    37 
    37     if(result)
    38     if(result)
       
    39     {
    38         assert_failed = 1;
    40         assert_failed = 1;
    39     
    41     } 
       
    42 
    40     testResultXml(xmlfile);
    43     testResultXml(xmlfile);
    41     close_log_file();
    44     close_log_file();
       
    45 
       
    46     if(result)
       
    47     {
       
    48         exit (-1);
       
    49     }    
       
    50 
    42 }
    51 }
    43 
    52 
    44 #include "libgstreamer_wsd_solution.h" 
    53 #include "libgstreamer_wsd_solution.h" 
    45 
    54 
    46 #if EMULATOR
    55 #if EMULATOR
   399 
   408 
   400   /* each object is referenced by a message;
   409   /* each object is referenced by a message;
   401    * base_src is blocked in the push and has an extra refcount.
   410    * base_src is blocked in the push and has an extra refcount.
   402    * base_sink_chain has taken a refcount on the sink, and is blocked on
   411    * base_sink_chain has taken a refcount on the sink, and is blocked on
   403    * preroll */
   412    * preroll */
   404   ASSERT_OBJECT_REFCOUNT (src, "src", 2);
   413   ASSERT_OBJECT_REFCOUNT (src, "src", 4);
   405   /* refcount can be 4 if the bin is still processing the async_done message of
   414   /* refcount can be 4 if the bin is still processing the async_done message of
   406    * the sink. */
   415    * the sink. */
   407   ASSERT_OBJECT_REFCOUNT_BETWEEN (sink, "sink", 2, 3);
   416   ASSERT_OBJECT_REFCOUNT_BETWEEN (sink, "sink", 2, 3);
   408   /* 2 or 3 is valid, because the pipeline might still be posting 
   417   /* 2 or 3 is valid, because the pipeline might still be posting 
   409    * its state_change message */
   418    * its state_change message */
   451   GST_DEBUG ("setting pipeline to READY");
   460   GST_DEBUG ("setting pipeline to READY");
   452   ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY);
   461   ret = gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_READY);
   453   fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
   462   fail_unless (ret == GST_STATE_CHANGE_SUCCESS);
   454 
   463 
   455   /* each object is referenced by two messages */
   464   /* each object is referenced by two messages */
   456   ASSERT_OBJECT_REFCOUNT (src, "src", 3);
   465   ASSERT_OBJECT_REFCOUNT (src, "src", 4);
   457   ASSERT_OBJECT_REFCOUNT (sink, "sink", 3);
   466   ASSERT_OBJECT_REFCOUNT (sink, "sink", 3);
   458   ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 3);
   467   ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 3);
   459 
   468 
   460   pop_messages (bus, 6);
   469   pop_messages (bus, 6);
   461   fail_if ((gst_bus_pop (bus)) != NULL);
   470   fail_if ((gst_bus_pop (bus)) != NULL);
  1026   gst_object_unref (pipeline);
  1035   gst_object_unref (pipeline);
  1027   std_log(LOG_FILENAME_LINE, "Test Successful");
  1036   std_log(LOG_FILENAME_LINE, "Test Successful");
  1028   create_xml(0); 
  1037   create_xml(0); 
  1029 }
  1038 }
  1030 
  1039 
       
  1040 static void
       
  1041 test_link_structure_change_state_changed_sync_cb (GstBus * bus,
       
  1042     GstMessage * message, gpointer data)
       
  1043 {
       
  1044   GstPipeline *pipeline = GST_PIPELINE (data);
       
  1045   GstElement *src, *identity, *sink;
       
  1046   GstState old, snew, pending;
       
  1047 
       
  1048   sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
       
  1049   fail_unless (sink != NULL, "Could not get sink");
       
  1050 
       
  1051   gst_message_parse_state_changed (message, &old, &snew, &pending);
       
  1052   if (message->src != GST_OBJECT (sink) || snew != GST_STATE_READY) {
       
  1053     gst_object_unref (sink);
       
  1054     return;
       
  1055   }
       
  1056 
       
  1057   src = gst_bin_get_by_name (GST_BIN (pipeline), "src");
       
  1058   fail_unless (src != NULL, "Could not get src");
       
  1059 
       
  1060   identity = gst_bin_get_by_name (GST_BIN (pipeline), "identity");
       
  1061   fail_unless (identity != NULL, "Could not get identity");
       
  1062 
       
  1063   /* link src to identity, the pipeline should detect the new link and
       
  1064    * resync the state change */
       
  1065   fail_unless (gst_element_link (src, identity) == TRUE);
       
  1066 
       
  1067   gst_object_unref (src);
       
  1068   gst_object_unref (identity);
       
  1069   gst_object_unref (sink);
       
  1070 }
       
  1071 
       
  1072 void test_link_structure_change()
       
  1073 {
       
  1074   GstElement *src, *identity, *sink, *pipeline;
       
  1075   GstBus *bus;
       
  1076   GstState state;
       
  1077   xmlfile = "test_link_structure_change";
       
  1078   std_log(LOG_FILENAME_LINE, "Test Started test_link_structure_change"); 
       
  1079   pipeline = gst_pipeline_new (NULL);
       
  1080   fail_unless (pipeline != NULL, "Could not create pipeline");
       
  1081 
       
  1082   bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
       
  1083   fail_unless (bus != NULL, "Could not get bus");
       
  1084 
       
  1085   /* use the sync signal handler to link elements while the pipeline is still
       
  1086    * doing the state change */
       
  1087   gst_bus_set_sync_handler (bus, gst_bus_sync_signal_handler, pipeline);
       
  1088   g_object_connect (bus, "signal::sync-message::state-changed",
       
  1089       G_CALLBACK (test_link_structure_change_state_changed_sync_cb), pipeline,
       
  1090       NULL);
       
  1091 
       
  1092   src = gst_element_factory_make ("fakesrc", "src");
       
  1093   fail_if (src == NULL, "Could not create fakesrc");
       
  1094 
       
  1095   identity = gst_element_factory_make ("identity", "identity");
       
  1096   fail_if (identity == NULL, "Could not create identity");
       
  1097 
       
  1098   sink = gst_element_factory_make ("fakesink", "sink");
       
  1099   fail_if (sink == NULL, "Could not create fakesink1");
       
  1100 
       
  1101   gst_bin_add_many (GST_BIN (pipeline), src, identity, sink, NULL);
       
  1102 
       
  1103   gst_element_set_state (pipeline, GST_STATE_READY);
       
  1104   gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
       
  1105 
       
  1106   /* the state change will be done on src only if the pipeline correctly resyncs
       
  1107    * after that filesrc has been linked to identity */
       
  1108   gst_element_get_state (src, &state, NULL, 0);
       
  1109   fail_unless_equals_int (state, GST_STATE_READY);
       
  1110 
       
  1111   gst_object_unref (bus);
       
  1112   gst_object_unref (pipeline);
       
  1113   
       
  1114   std_log(LOG_FILENAME_LINE, "Test test_link_structure_change Successful");
       
  1115   create_xml(0); 
       
  1116 }
       
  1117 
       
  1118 
  1031 void (*fn[]) (void) = {
  1119 void (*fn[]) (void) = {
  1032 test_message_state_changed,
  1120 test_message_state_changed,
  1033 test_interface,
  1121 test_interface,
  1034 test_message_state_changed_child,
  1122 test_message_state_changed_child,
  1035 test_message_state_changed_children,
  1123 test_message_state_changed_children,
  1037 test_add_linked,
  1125 test_add_linked,
  1038 test_add_self,
  1126 test_add_self,
  1039 test_iterate_sorted,
  1127 test_iterate_sorted,
  1040 test_children_state_change_order_flagged_sink,
  1128 test_children_state_change_order_flagged_sink,
  1041 test_children_state_change_order_semi_sink,
  1129 test_children_state_change_order_semi_sink,
  1042 test_children_state_change_order_two_sink
  1130 test_children_state_change_order_two_sink,
       
  1131 test_link_structure_change
  1043 };
  1132 };
  1044 
  1133 
  1045 char *args[] = {
  1134 char *args[] = {
  1046 "test_message_state_changed",
  1135 "test_message_state_changed",
  1047 "test_interface",
  1136 "test_interface",
  1051 "test_add_linked",
  1140 "test_add_linked",
  1052 "test_add_self",
  1141 "test_add_self",
  1053 "test_iterate_sorted",
  1142 "test_iterate_sorted",
  1054 "test_children_state_change_order_flagged_sink",
  1143 "test_children_state_change_order_flagged_sink",
  1055 "test_children_state_change_order_semi_sink",
  1144 "test_children_state_change_order_semi_sink",
  1056 "test_children_state_change_order_two_sink"
  1145 "test_children_state_change_order_two_sink",
       
  1146 "test_link_structure_change"
  1057 };
  1147 };
  1058 
  1148 
  1059 GST_CHECK_MAIN (gst_bin);
  1149 GST_CHECK_MAIN (gst_bin);
  1060 
  1150 
  1061 #if 0
  1151 #if 0