Exemplo n.º 1
0
static int json_on_video_tag(flv_tag * tag, flv_video_tag vt, flv_parser * parser) {
    json_emitter * je;
    je = (json_emitter*)parser->user_data;

    json_emit_object_key_z(je, "videoData");
    json_emit_object_start(je);
    json_emit_object_key_z(je, "codecID");
    json_emit_string_z(je, dump_string_get_video_codec(vt));
    json_emit_object_key_z(je, "frameType");
    json_emit_string_z(je, dump_string_get_video_frame_type(vt));

    /* if AVC, detect frame type and composition time */
    if (flv_video_tag_codec_id(vt) == FLV_VIDEO_TAG_CODEC_AVC) {
        flv_avc_packet_type type;

        /* packet type */
        if (flv_read_tag_body(parser->stream, &type, sizeof(flv_avc_packet_type)) < sizeof(flv_avc_packet_type)) {
            return ERROR_INVALID_TAG;
        }

        json_emit_object_key_z(je, "AVCData");

        json_emit_object_start(je);
        json_emit_object_key_z(je, "packetType");
        json_emit_string_z(je, dump_string_get_avc_packet_type(type));

        /* composition time */
        if (type == FLV_AVC_PACKET_TYPE_NALU) {
            uint24_be composition_time;

            if (flv_read_tag_body(parser->stream, &composition_time, sizeof(uint24_be)) < sizeof(uint24_be)) {
                return ERROR_INVALID_TAG;
            }

            json_emit_object_key_z(je, "compositionTimeOffset");
            json_emit_integer(je, uint24_be_to_uint32(composition_time));
        }

        json_emit_object_end(je);
    }

    json_emit_object_end(je);

    return OK;
}
Exemplo n.º 2
0
static int xml_on_video_tag(flv_tag * tag, flv_video_tag vt, flv_parser * parser) {
    printf("    <videoData codecID=\"%s\"", dump_string_get_video_codec(vt));
    printf(" frameType=\"%s\"/>\n", dump_string_get_video_frame_type(vt));
    return OK;
}
Exemplo n.º 3
0
static int raw_on_video_tag(flv_tag * tag, flv_video_tag vt, flv_parser * parser) {
    printf("* Video codec: %s\n", dump_string_get_video_codec(vt));
    printf("* Video frame type: %s\n", dump_string_get_video_frame_type(vt));
    return OK;
}
Exemplo n.º 4
0
static int json_on_video_tag(flv_tag * tag, flv_video_tag vt, flv_parser * parser) {
    printf("\"videoData\":{\"codecID\":\"%s\"", dump_string_get_video_codec(vt));
    printf(",\"frameType\":\"%s\"}", dump_string_get_video_frame_type(vt));
    return OK;
}