00-test-rtp-payloading.patch 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. From dca42d4767adff3578e5d5990604766735ec1f9b Mon Sep 17 00:00:00 2001
  2. From: Tim-Philipp Müller <tim.muller@collabora.co.uk>
  3. Date: Fri, 10 Feb 2012 13:44:43 +0000
  4. Subject: tests: clean up rtp-payloading test a little
  5. Feed data into the pipeline using appsrc instead of fdsrc and
  6. a pipe. Store unsigned byte values in guint8 instead of char.
  7. Getting rid of the capsfilter also helps to avoid 'format is
  8. not fully specified' warnings when pushing "video/x-h264" data
  9. into rtph264pay with fully specified h264 caps in the sink template.
  10. ---
  11. diff --git a/tests/check/elements/rtp-payloading.c b/tests/check/elements/rtp-payloading.c
  12. index b2160f4..7b4985b 100644
  13. --- a/tests/check/elements/rtp-payloading.c
  14. +++ b/tests/check/elements/rtp-payloading.c
  15. @@ -31,13 +31,11 @@
  16. typedef struct
  17. {
  18. GstElement *pipeline;
  19. - GstElement *fdsrc;
  20. - GstElement *capsfilter;
  21. + GstElement *appsrc;
  22. GstElement *rtppay;
  23. GstElement *rtpdepay;
  24. GstElement *fakesink;
  25. - int fd[2];
  26. - const char *frame_data;
  27. + const guint8 *frame_data;
  28. int frame_data_size;
  29. int frame_count;
  30. } rtp_pipeline;
  31. @@ -140,13 +138,11 @@ rtp_bus_callback (GstBus * bus, GstMessage * message, gpointer data)
  32. * The user must free the RTP pipeline when it's not used anymore.
  33. */
  34. static rtp_pipeline *
  35. -rtp_pipeline_create (const char *frame_data, int frame_data_size,
  36. +rtp_pipeline_create (const guint8 * frame_data, int frame_data_size,
  37. int frame_count, const char *filtercaps, const char *pay, const char *depay)
  38. {
  39. gchar *pipeline_name;
  40. -
  41. rtp_pipeline *p;
  42. -
  43. GstCaps *caps;
  44. /* Check parameters. */
  45. @@ -165,60 +161,39 @@ rtp_pipeline_create (const char *frame_data, int frame_data_size,
  46. pipeline_name = g_strdup_printf ("%s-%s-pipeline", pay, depay);
  47. p->pipeline = gst_pipeline_new (pipeline_name);
  48. g_free (pipeline_name);
  49. - p->fdsrc = gst_element_factory_make ("fdsrc", NULL);
  50. - p->capsfilter = gst_element_factory_make ("capsfilter", NULL);
  51. + p->appsrc = gst_element_factory_make ("appsrc", NULL);
  52. p->rtppay = gst_element_factory_make (pay, NULL);
  53. p->rtpdepay = gst_element_factory_make (depay, NULL);
  54. p->fakesink = gst_element_factory_make ("fakesink", NULL);
  55. /* One or more elements are not created successfully or failed to create p? */
  56. - if (!p->pipeline || !p->fdsrc || !p->capsfilter || !p->rtppay || !p->rtpdepay
  57. - || !p->fakesink || pipe (p->fd) == -1) {
  58. + if (!p->pipeline || !p->appsrc || !p->rtppay || !p->rtpdepay || !p->fakesink) {
  59. /* Release created elements. */
  60. RELEASE_ELEMENT (p->pipeline);
  61. - RELEASE_ELEMENT (p->fdsrc);
  62. - RELEASE_ELEMENT (p->capsfilter);
  63. + RELEASE_ELEMENT (p->appsrc);
  64. RELEASE_ELEMENT (p->rtppay);
  65. RELEASE_ELEMENT (p->rtpdepay);
  66. RELEASE_ELEMENT (p->fakesink);
  67. - /* Close pipe. */
  68. - if (p->fd[0]) {
  69. - close (p->fd[0]);
  70. - }
  71. -
  72. - if (p->fd[1]) {
  73. - close (p->fd[1]);
  74. - }
  75. -
  76. /* Release allocated memory. */
  77. free (p);
  78. return NULL;
  79. }
  80. - /* Set fdsrc properties. */
  81. - g_object_set (p->fdsrc, "fd", p->fd[0], NULL);
  82. - g_object_set (p->fdsrc, "do-timestamp", TRUE, NULL);
  83. - g_object_set (p->fdsrc, "blocksize", p->frame_data_size, NULL);
  84. - g_object_set (p->fdsrc, "num-buffers", p->frame_count * LOOP_COUNT, NULL);
  85. -
  86. - /* Set caps filters. */
  87. + /* Set src properties. */
  88. caps = gst_caps_from_string (filtercaps);
  89. -
  90. - g_object_set (p->capsfilter, "caps", caps, NULL);
  91. + g_object_set (p->appsrc, "do-timestamp", TRUE, "caps", caps, NULL);
  92. gst_caps_unref (caps);
  93. /* Add elements to the pipeline. */
  94. - gst_bin_add (GST_BIN (p->pipeline), p->fdsrc);
  95. - gst_bin_add (GST_BIN (p->pipeline), p->capsfilter);
  96. + gst_bin_add (GST_BIN (p->pipeline), p->appsrc);
  97. gst_bin_add (GST_BIN (p->pipeline), p->rtppay);
  98. gst_bin_add (GST_BIN (p->pipeline), p->rtpdepay);
  99. gst_bin_add (GST_BIN (p->pipeline), p->fakesink);
  100. /* Link elements. */
  101. - gst_element_link (p->fdsrc, p->capsfilter);
  102. - gst_element_link (p->capsfilter, p->rtppay);
  103. + gst_element_link (p->appsrc, p->rtppay);
  104. gst_element_link (p->rtppay, p->rtpdepay);
  105. gst_element_link (p->rtpdepay, p->fakesink);
  106. @@ -240,15 +215,6 @@ rtp_pipeline_destroy (rtp_pipeline * p)
  107. /* Release pipeline. */
  108. RELEASE_ELEMENT (p->pipeline);
  109. - /* Close pipe. */
  110. - if (p->fd[0]) {
  111. - close (p->fd[0]);
  112. - }
  113. -
  114. - if (p->fd[1]) {
  115. - close (p->fd[1]);
  116. - }
  117. -
  118. /* Release allocated memory. */
  119. free (p);
  120. }
  121. @@ -260,11 +226,10 @@ rtp_pipeline_destroy (rtp_pipeline * p)
  122. static void
  123. rtp_pipeline_run (rtp_pipeline * p)
  124. {
  125. + GstFlowReturn flow_ret;
  126. GMainLoop *mainloop = NULL;
  127. -
  128. GstBus *bus;
  129. -
  130. - gint i;
  131. + gint i, j;
  132. /* Check parameters. */
  133. if (p == NULL) {
  134. @@ -286,22 +251,28 @@ rtp_pipeline_run (rtp_pipeline * p)
  135. /* Set pipeline to PLAYING. */
  136. gst_element_set_state (p->pipeline, GST_STATE_PLAYING);
  137. - /* TODO: Writing may need some changes... */
  138. -
  139. + /* Push data into the pipeline */
  140. for (i = 0; i < LOOP_COUNT; i++) {
  141. - const char *frame_data_pointer = p->frame_data;
  142. - int res;
  143. - int frame_count = p->frame_count;
  144. -
  145. - /* Write in to the pipe. */
  146. - while (frame_count > 0) {
  147. - res = write (p->fd[1], frame_data_pointer, p->frame_data_size);
  148. - fail_unless_equals_int (res, p->frame_data_size);
  149. - frame_data_pointer += p->frame_data_size;
  150. - frame_count--;
  151. + const guint8 *data = p->frame_data;
  152. +
  153. + for (j = 0; j < p->frame_count; j++) {
  154. + GstBuffer *buf;
  155. +
  156. + buf = gst_buffer_new ();
  157. + GST_BUFFER_DATA (buf) = (guint8 *) data;
  158. + GST_BUFFER_SIZE (buf) = p->frame_data_size;
  159. + GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_READONLY);
  160. +
  161. + g_signal_emit_by_name (p->appsrc, "push-buffer", buf, &flow_ret);
  162. + fail_unless_equals_int (flow_ret, GST_FLOW_OK);
  163. + data += p->frame_data_size;
  164. +
  165. + gst_buffer_unref (buf);
  166. }
  167. }
  168. + g_signal_emit_by_name (p->appsrc, "end-of-stream", &flow_ret);
  169. +
  170. /* Run mainloop. */
  171. g_main_loop_run (mainloop);
  172. @@ -350,8 +321,8 @@ rtp_pipeline_enable_lists (rtp_pipeline * p, guint mtu_size)
  173. * @use_lists enable buffer lists
  174. */
  175. static void
  176. -rtp_pipeline_test (const char *frame_data, int frame_data_size, int frame_count,
  177. - const char *filtercaps, const char *pay, const char *depay,
  178. +rtp_pipeline_test (const guint8 * frame_data, int frame_data_size,
  179. + int frame_count, const char *filtercaps, const char *pay, const char *depay,
  180. guint bytes_sent, guint mtu_size, gboolean use_lists)
  181. {
  182. /* Create RTP pipeline. */
  183. @@ -380,7 +351,7 @@ rtp_pipeline_test (const char *frame_data, int frame_data_size, int frame_count,
  184. }
  185. }
  186. -static char rtp_ilbc_frame_data[] =
  187. +static const guint8 rtp_ilbc_frame_data[] =
  188. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  189. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  190. };
  191. @@ -397,7 +368,7 @@ GST_START_TEST (rtp_ilbc)
  192. }
  193. GST_END_TEST;
  194. -static char rtp_gsm_frame_data[] =
  195. +static const guint8 rtp_gsm_frame_data[] =
  196. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  197. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  198. };
  199. @@ -414,7 +385,7 @@ GST_START_TEST (rtp_gsm)
  200. }
  201. GST_END_TEST;
  202. -static char rtp_amr_frame_data[] =
  203. +static const guint8 rtp_amr_frame_data[] =
  204. { 0x3c, 0x24, 0x03, 0xb3, 0x48, 0x10, 0x68, 0x46, 0x6c, 0xec, 0x03,
  205. 0x7a, 0x37, 0x16, 0x41, 0x41, 0xc0, 0x00, 0x0d, 0xcd, 0x12, 0xed,
  206. 0xad, 0x80, 0x00, 0x00, 0x11, 0x31, 0x00, 0x00, 0x0d, 0xa0
  207. @@ -432,7 +403,7 @@ GST_START_TEST (rtp_amr)
  208. }
  209. GST_END_TEST;
  210. -static char rtp_pcma_frame_data[] =
  211. +static const guint8 rtp_pcma_frame_data[] =
  212. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  213. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  214. };
  215. @@ -449,7 +420,7 @@ GST_START_TEST (rtp_pcma)
  216. }
  217. GST_END_TEST;
  218. -static char rtp_pcmu_frame_data[] =
  219. +static const guint8 rtp_pcmu_frame_data[] =
  220. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  221. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  222. };
  223. @@ -466,7 +437,7 @@ GST_START_TEST (rtp_pcmu)
  224. }
  225. GST_END_TEST;
  226. -static char rtp_mpa_frame_data[] =
  227. +static const guint8 rtp_mpa_frame_data[] =
  228. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  229. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  230. };
  231. @@ -483,7 +454,7 @@ GST_START_TEST (rtp_mpa)
  232. }
  233. GST_END_TEST;
  234. -static char rtp_h263_frame_data[] =
  235. +static const guint8 rtp_h263_frame_data[] =
  236. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  237. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  238. };
  239. @@ -495,12 +466,12 @@ static int rtp_h263_frame_count = 1;
  240. GST_START_TEST (rtp_h263)
  241. {
  242. rtp_pipeline_test (rtp_h263_frame_data, rtp_h263_frame_data_size,
  243. - rtp_h263_frame_count, "video/x-h263,variant=itu,h263version=h263",
  244. + rtp_h263_frame_count, "video/x-h263,variant=(string)itu,h263version=h263",
  245. "rtph263pay", "rtph263depay", 0, 0, FALSE);
  246. }
  247. GST_END_TEST;
  248. -static char rtp_h263p_frame_data[] =
  249. +static const guint8 rtp_h263p_frame_data[] =
  250. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  251. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  252. };
  253. @@ -512,12 +483,12 @@ static int rtp_h263p_frame_count = 1;
  254. GST_START_TEST (rtp_h263p)
  255. {
  256. rtp_pipeline_test (rtp_h263p_frame_data, rtp_h263p_frame_data_size,
  257. - rtp_h263p_frame_count, "video/x-h263,variant=itu", "rtph263ppay",
  258. + rtp_h263p_frame_count, "video/x-h263,variant=(string)itu", "rtph263ppay",
  259. "rtph263pdepay", 0, 0, FALSE);
  260. }
  261. GST_END_TEST;
  262. -static char rtp_h264_frame_data[] =
  263. +static const guint8 rtp_h264_frame_data[] =
  264. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  265. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  266. };
  267. @@ -528,13 +499,14 @@ static int rtp_h264_frame_count = 1;
  268. GST_START_TEST (rtp_h264)
  269. {
  270. + /* FIXME 0.11: fully specify h264 caps (and make payloader check) */
  271. rtp_pipeline_test (rtp_h264_frame_data, rtp_h264_frame_data_size,
  272. rtp_h264_frame_count, "video/x-h264", "rtph264pay", "rtph264depay",
  273. 0, 0, FALSE);
  274. }
  275. GST_END_TEST;
  276. -static char rtp_h264_list_lt_mtu_frame_data[] =
  277. +static const guint8 rtp_h264_list_lt_mtu_frame_data[] =
  278. /* not packetized, next NAL starts with 0001 */
  279. { 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
  280. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
  281. @@ -552,6 +524,7 @@ static int rtp_h264_list_lt_mtu_mtu_size = 1024;
  282. GST_START_TEST (rtp_h264_list_lt_mtu)
  283. {
  284. + /* FIXME 0.11: fully specify h264 caps (and make payloader check) */
  285. rtp_pipeline_test (rtp_h264_list_lt_mtu_frame_data,
  286. rtp_h264_list_lt_mtu_frame_data_size, rtp_h264_list_lt_mtu_frame_count,
  287. "video/x-h264", "rtph264pay", "rtph264depay",
  288. @@ -559,7 +532,7 @@ GST_START_TEST (rtp_h264_list_lt_mtu)
  289. }
  290. GST_END_TEST;
  291. -static char rtp_h264_list_gt_mtu_frame_data[] =
  292. +static const guint8 rtp_h264_list_gt_mtu_frame_data[] =
  293. /* not packetized, next NAL starts with 0001 */
  294. { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  295. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  296. @@ -580,6 +553,7 @@ static int rtp_h264_list_gt_mtu_mty_size = 28;
  297. GST_START_TEST (rtp_h264_list_gt_mtu)
  298. {
  299. + /* FIXME 0.11: fully specify h264 caps (and make payloader check) */
  300. rtp_pipeline_test (rtp_h264_list_gt_mtu_frame_data,
  301. rtp_h264_list_gt_mtu_frame_data_size, rtp_h264_list_gt_mtu_frame_count,
  302. "video/x-h264", "rtph264pay", "rtph264depay",
  303. @@ -587,7 +561,7 @@ GST_START_TEST (rtp_h264_list_gt_mtu)
  304. }
  305. GST_END_TEST;
  306. -static char rtp_L16_frame_data[] =
  307. +static const guint8 rtp_L16_frame_data[] =
  308. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  309. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  310. };
  311. @@ -605,7 +579,7 @@ GST_START_TEST (rtp_L16)
  312. }
  313. GST_END_TEST;
  314. -static char rtp_mp2t_frame_data[] =
  315. +static const guint8 rtp_mp2t_frame_data[] =
  316. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  317. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  318. };
  319. @@ -622,7 +596,7 @@ GST_START_TEST (rtp_mp2t)
  320. }
  321. GST_END_TEST;
  322. -static char rtp_mp4v_frame_data[] =
  323. +static const guint8 rtp_mp4v_frame_data[] =
  324. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  325. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  326. };
  327. @@ -639,7 +613,7 @@ GST_START_TEST (rtp_mp4v)
  328. }
  329. GST_END_TEST;
  330. -static char rtp_mp4v_list_frame_data[] =
  331. +static const guint8 rtp_mp4v_list_frame_data[] =
  332. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  333. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  334. };
  335. @@ -659,7 +633,7 @@ GST_START_TEST (rtp_mp4v_list)
  336. }
  337. GST_END_TEST;
  338. -static char rtp_mp4g_frame_data[] =
  339. +static const guint8 rtp_mp4g_frame_data[] =
  340. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  341. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  342. };
  343. @@ -677,7 +651,7 @@ GST_START_TEST (rtp_mp4g)
  344. }
  345. GST_END_TEST;
  346. -static char rtp_theora_frame_data[] =
  347. +static const guint8 rtp_theora_frame_data[] =
  348. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  349. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  350. };
  351. @@ -694,7 +668,7 @@ GST_START_TEST (rtp_theora)
  352. }
  353. GST_END_TEST;
  354. -static char rtp_vorbis_frame_data[] =
  355. +static const guint8 rtp_vorbis_frame_data[] =
  356. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  357. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  358. };
  359. @@ -711,7 +685,7 @@ GST_START_TEST (rtp_vorbis)
  360. }
  361. GST_END_TEST;
  362. -static char rtp_jpeg_frame_data[] =
  363. +static const guint8 rtp_jpeg_frame_data[] =
  364. { /* SOF */ 0xFF, 0xC0, 0x00, 0x11, 0x08, 0x00, 0x08, 0x00, 0x08,
  365. 0x03, 0x00, 0x21, 0x08, 0x01, 0x11, 0x08, 0x02, 0x11, 0x08,
  366. /* DQT */ 0xFF, 0xDB, 0x00, 0x43, 0x08,
  367. @@ -738,7 +712,7 @@ GST_START_TEST (rtp_jpeg)
  368. }
  369. GST_END_TEST;
  370. -static char rtp_jpeg_list_frame_data[] =
  371. +static const guint8 rtp_jpeg_list_frame_data[] =
  372. { /* SOF */ 0xFF, 0xC0, 0x00, 0x11, 0x08, 0x00, 0x08, 0x00, 0x08,
  373. 0x03, 0x00, 0x21, 0x08, 0x01, 0x11, 0x08, 0x02, 0x11, 0x08,
  374. /* DQT */ 0xFF, 0xDB, 0x00, 0x43, 0x08,
  375. @@ -767,7 +741,7 @@ GST_START_TEST (rtp_jpeg_list)
  376. }
  377. GST_END_TEST;
  378. -static char rtp_g729_frame_data[] =
  379. +static const guint8 rtp_g729_frame_data[] =
  380. { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  381. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  382. };
  383. --
  384. cgit v0.9.0.2-2-gbebe