83 GST_DEBUG_CATEGORY_STATIC (data_protocol_debug); |
83 GST_DEBUG_CATEGORY_STATIC (data_protocol_debug); |
84 #define GST_CAT_DEFAULT data_protocol_debug |
84 #define GST_CAT_DEFAULT data_protocol_debug |
85 |
85 |
86 /* helper macros */ |
86 /* helper macros */ |
87 |
87 |
88 /* write first 6 bytes of header */ |
88 /* write first 6 bytes of header, as well as ABI padding */ |
89 #define GST_DP_INIT_HEADER(h, version, flags, type) \ |
89 #define GST_DP_INIT_HEADER(h, version, flags, type) \ |
90 G_STMT_START { \ |
90 G_STMT_START { \ |
91 gint maj = 0, min = 0; \ |
91 gint maj = 0, min = 0; \ |
92 switch (version) { \ |
92 switch (version) { \ |
93 case GST_DP_VERSION_0_2: maj = 0; min = 2; break; \ |
93 case GST_DP_VERSION_0_2: maj = 0; min = 2; break; \ |
96 h[0] = (guint8) maj; \ |
96 h[0] = (guint8) maj; \ |
97 h[1] = (guint8) min; \ |
97 h[1] = (guint8) min; \ |
98 h[2] = (guint8) flags; \ |
98 h[2] = (guint8) flags; \ |
99 h[3] = 0; /* padding byte */ \ |
99 h[3] = 0; /* padding byte */ \ |
100 GST_WRITE_UINT16_BE (h + 4, type); \ |
100 GST_WRITE_UINT16_BE (h + 4, type); \ |
|
101 \ |
|
102 GST_WRITE_UINT64_BE (h + 42, (guint64) 0); /* ABI padding */ \ |
|
103 GST_WRITE_UINT64_BE (h + 50, (guint64) 0); /* ABI padding */ \ |
101 } G_STMT_END |
104 } G_STMT_END |
102 |
105 |
103 #define GST_DP_SET_CRC(h, flags, payload, length); \ |
106 #define GST_DP_SET_CRC(h, flags, payload, length); \ |
104 G_STMT_START { \ |
107 G_STMT_START { \ |
105 guint16 crc = 0; \ |
108 guint16 crc = 0; \ |
125 |
128 |
126 #define POLY 0x1021 |
129 #define POLY 0x1021 |
127 #define CRC_INIT 0xFFFF |
130 #define CRC_INIT 0xFFFF |
128 |
131 |
129 /*** HELPER FUNCTIONS ***/ |
132 /*** HELPER FUNCTIONS ***/ |
|
133 |
130 |
134 |
131 static gboolean |
135 static gboolean |
132 gst_dp_header_from_buffer_any (const GstBuffer * buffer, GstDPHeaderFlag flags, |
136 gst_dp_header_from_buffer_any (const GstBuffer * buffer, GstDPHeaderFlag flags, |
133 guint * length, guint8 ** header, GstDPVersion version) |
137 guint * length, guint8 ** header, GstDPVersion version) |
134 { |
138 { |
219 string = (guchar *) gst_caps_to_string (caps); |
223 string = (guchar *) gst_caps_to_string (caps); |
220 payload_length = strlen ((gchar *) string) + 1; /* include trailing 0 */ |
224 payload_length = strlen ((gchar *) string) + 1; /* include trailing 0 */ |
221 #if defined(__WINSCW__) || defined(__WINS__) |
225 #if defined(__WINSCW__) || defined(__WINS__) |
222 /* version, flags, type */ |
226 /* version, flags, type */ |
223 GST_DP_INIT_HEADER (h, version, flags, GST_DP_PAYLOAD_CAPS); |
227 GST_DP_INIT_HEADER (h, version, flags, GST_DP_PAYLOAD_CAPS); |
224 |
228 |
225 /* buffer properties */ |
|
226 GST_WRITE_UINT32_BE (h + 6, payload_length); |
229 GST_WRITE_UINT32_BE (h + 6, payload_length); |
227 GST_WRITE_UINT64_BE (h + 10, (guint64) 0); |
230 GST_WRITE_UINT64_BE (h + 10, (guint64) 0); |
228 GST_WRITE_UINT64_BE (h + 18, (guint64) 0); |
231 GST_WRITE_UINT64_BE (h + 18, (guint64) 0); |
229 GST_WRITE_UINT64_BE (h + 26, (guint64) 0); |
232 GST_WRITE_UINT64_BE (h + 26, (guint64) 0); |
230 GST_WRITE_UINT64_BE (h + 34, (guint64) 0); |
233 GST_WRITE_UINT64_BE (h + 34, (guint64) 0); |
595 /* version, flags, type */ |
598 /* version, flags, type */ |
596 GST_DP_INIT_HEADER (h, GST_DP_VERSION_0_2, flags, |
599 GST_DP_INIT_HEADER (h, GST_DP_VERSION_0_2, flags, |
597 GST_DP_PAYLOAD_EVENT_NONE + GST_EVENT_TYPE (event)); |
600 GST_DP_PAYLOAD_EVENT_NONE + GST_EVENT_TYPE (event)); |
598 |
601 |
599 /* length */ |
602 /* length */ |
|
603 |
600 GST_WRITE_UINT32_BE (h + 6, (guint32) pl_length); |
604 GST_WRITE_UINT32_BE (h + 6, (guint32) pl_length); |
601 /* timestamp */ |
605 /* timestamp */ |
602 GST_WRITE_UINT64_BE (h + 10, GST_EVENT_TIMESTAMP (event)); |
606 GST_WRITE_UINT64_BE (h + 10, GST_EVENT_TIMESTAMP (event)); |
603 |
607 |
604 GST_DP_SET_CRC (h, flags, *payload, pl_length); |
608 GST_DP_SET_CRC (h, flags, *payload, pl_length); |
673 /* length */ |
677 /* length */ |
674 GST_WRITE_UINT32_BE (h + 6, pl_length); |
678 GST_WRITE_UINT32_BE (h + 6, pl_length); |
675 /* timestamp */ |
679 /* timestamp */ |
676 GST_WRITE_UINT64_BE (h + 10, GST_EVENT_TIMESTAMP (event)); |
680 GST_WRITE_UINT64_BE (h + 10, GST_EVENT_TIMESTAMP (event)); |
677 |
681 |
678 GST_DP_SET_CRC (h, flags, string, pl_length); |
682 GST_DP_SET_CRC (h, flags, *payload, pl_length); |
679 |
683 |
680 GST_LOG ("created header from event:"); |
684 GST_LOG ("created header from event:"); |
681 gst_dp_dump_byte_array (h, GST_DP_HEADER_LENGTH); |
685 gst_dp_dump_byte_array (h, GST_DP_HEADER_LENGTH); |
682 *header = h; |
686 *header = h; |
683 #else |
687 #else |
691 GST_WRITE_UINT32_BE (tmp + 6, pl_length); |
695 GST_WRITE_UINT32_BE (tmp + 6, pl_length); |
692 /* timestamp */ |
696 /* timestamp */ |
693 tmp = tmp + 10; |
697 tmp = tmp + 10; |
694 GST_WRITE_UINT64_BE (tmp, GST_EVENT_TIMESTAMP (event)); |
698 GST_WRITE_UINT64_BE (tmp, GST_EVENT_TIMESTAMP (event)); |
695 |
699 |
696 GST_DP_SET_CRC ((guint8 *)h, flags, string, pl_length); |
700 GST_DP_SET_CRC ((guint8 *)h, flags, *payload, pl_length); |
697 |
701 |
698 GST_LOG ("created header from event:"); |
702 GST_LOG ("created header from event:"); |
699 gst_dp_dump_byte_array ((guint8 *)h, GST_DP_HEADER_LENGTH); |
703 gst_dp_dump_byte_array ((guint8 *)h, GST_DP_HEADER_LENGTH); |
700 *header = (guint8 *)h; |
704 *header = (guint8 *)h; |
701 #endif |
705 #endif |