Example #1
0
        public void JsonLikeParserTest()
        {
            var token    = JsonLikeStringParser.Parse(@"{decoders: [{decoder: (VideoDecoder), payload_type: 96, payload_name: VP8, codec_params: {}}, {decoder: (VideoDecoder), payload_type: 98, payload_name: VP9, codec_params: {}}, {decoder: (VideoDecoder), payload_type: 100, payload_name: H264, codec_params: {level-asymmetry-allowed: 1packetization-mode: 1profile-level-id: 42e01f}}], rtp: {remote_ssrc: 2518741716, local_ssrc: 3473758211, rtcp_mode: RtcpMode::kReducedSize, rtcp_xr: {receiver_reference_time_report: off}, remb: on, transport_cc: on, nack: {rtp_history_ms: 1000}, ulpfec: {ulpfec_payload_type: 127, red_payload_type: 102, red_rtx_payload_type: 125}, rtx_ssrc: 2508991752, rtx_payload_types: {96 (apt) -> 97 (pt), 98 (apt) -> 99 (pt), 100 (apt) -> 101 (pt), }, extensions: [{uri: http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01, id: 5}, {uri: http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time, id: 3}, {uri: http://www.webrtc.org/experiments/rtp-hdrext/playout-delay, id: 6}, {uri: urn:3gpp:video-orientation, id: 4}, {uri: urn:ietf:params:rtp-hdrext:toffset, id: 2}]}, renderer: (renderer), render_delay_ms: 10, sync_group: h0Gv19oeTn3moIjfzPmh0hmOvCJwDYdVm5E9, pre_decode_callback: nullptr, target_delay_ms: 0}");
            var actual   = token.ToString(Newtonsoft.Json.Formatting.Indented);
            var expected = Utils.GetResourceStream("JsonLikeParserTest01");

            Utils.AssertTextsAreEqualLineByLine(
                Utils.SplitTextStream(expected),
                Utils.SplitText(actual)
                );
        }
        private void HandleStreamCtrDtrMessage(Queue <Event> buffer, Message msg, Regex re, string type)
        {
            Match m;

            if ((m = re.Match(msg.Text)).Success)
            {
                var objid = m.Groups["id"].Value;
                if (m.Groups["dtr"].Length == 0)
                {
                    buffer.Enqueue(new ObjectCreation(msg, objid, streamTypeInfo));
                    buffer.Enqueue(new ParentChildRelationChange(msg, objid, streamTypeInfo, streamsRootObjectId));
                    buffer.Enqueue(new PropertyChange(msg, objid, streamTypeInfo, "type", type));
                    buffer.Enqueue(new PropertyChange(msg, objid, streamTypeInfo, "SSRC", objid));
                    PrintJson(JsonLikeStringParser.Parse(m.Groups["json"].Value), buffer, msg, objid, streamTypeInfo, propName: null,
                              converter: (node, propName) =>
                    {
                        if (propName == "extensions" && node is JArray)
                        {
                            return(new JObject(
                                       from ext in node.OfType <JObject>()
                                       let id = ext.Property("id")
                                                let uri = ext.Property("uri")
                                                          where id != null && uri != null
                                                          select new JProperty(id.Value.ToString(), uri.Value)
                                       ));
                        }
                        return(node);
                    },
                              getValueType: propName =>
                    {
                        if (propName == "local_ssrc")
                        {
                            return(Analytics.StateInspector.ValueType.Reference);
                        }
                        return(Analytics.StateInspector.ValueType.Scalar);
                    }
                              );
                }
                else
                {
                    buffer.Enqueue(new ObjectDeletion(msg, objid, streamTypeInfo));
                }
            }
        }