Example #1
0
def frame_manipulator(pipeline, name):

    #
    # This pipeline reads the channels needed for calibration from the raw frames
    # and writes them to smaller frames for faster access.
    #

    head_dict = {}

    # Get the data from the raw frames and pick out the channels we want
    src = pipeparts.mklalcachesrc(pipeline,
                                  location=frame_cache,
                                  cache_dsc_regex=ifo)
    src = pipeparts.mkprogressreport(pipeline, src, "start")
    demux = pipeparts.mkframecppchanneldemux(pipeline,
                                             src,
                                             do_file_checksum=False,
                                             skip_bad_files=True,
                                             channel_list=list(
                                                 map("%s:%s".__mod__,
                                                     ifo_channel_list)))

    # Make a muxer to collect the channels we need
    channelmux_input_dict = {}
    for key, chan in zip(channel_list, channel_list):
        head_dict[key] = calibration_parts.hook_up(pipeline, demux, chan, ifo,
                                                   1.0)
        head_dict[key] = pipeparts.mkprogressreport(pipeline, head_dict[key],
                                                    "before muxer %s" % key)
        channelmux_input_dict["%s:%s" %
                              (ifo, chan)] = calibration_parts.mkqueue(
                                  pipeline, head_dict[key])

    if output_path == 'txt':
        for chan in channel_list:
            pipeparts.mknxydumpsink(
                pipeline, channelmux_input_dict["%s:%s" % (ifo, chan)],
                "%s-%s.txt" % (ifo, chan))
    else:
        mux = pipeparts.mkframecppchannelmux(pipeline,
                                             channelmux_input_dict,
                                             frame_duration=frame_length,
                                             frames_per_file=frames_per_file,
                                             compression_scheme=6,
                                             compression_level=3)
        mux = pipeparts.mkprogressreport(pipeline, mux, "end")
        pipeparts.mkframecppfilesink(pipeline,
                                     mux,
                                     frame_type=frame_type,
                                     path=output_path,
                                     instrument=ifo)

    #
    # done
    #

    return pipeline
Example #2
0
def build_pipeline(pipeline,
                   data_source_info,
                   output_path=tempfile.gettempdir(),
                   sample_rate=None,
                   description="TMPFILE_DELETE_ME_%s" % uuid.uuid4().hex,
                   channel_comment=None,
                   frame_duration=1,
                   frames_per_file=1024,
                   verbose=False):
    #
    # get instrument and channel name (requires exactly one
    # instrument+channel)
    #

    channelmux_input_dict = {}

    for instrument, channel_name in data_source_info.channel_dict.items():
        #
        # retrieve h(t)
        #

        src = mkbasicsrc(pipeline,
                         data_source_info,
                         instrument,
                         verbose=verbose)

        #
        # optionally resample
        #

        if sample_rate is not None:
            # make sure we're *down*sampling
            src = pipeparts.mkcapsfilter(
                pipeline, src, "audio/x-raw, rate=[%d,MAX]" % sample_rate)
            src = pipeparts.mkresample(pipeline, src, quality=9)
            src = pipeparts.mkcapsfilter(pipeline, src,
                                         "audio/x-raw, rate=%d" % sample_rate)

        #
        # pack into frame files for output
        #

        src = pipeparts.mkframecppchannelmux(
            pipeline, {"%s:%s" % (instrument, channel_name): src},
            frame_duration=frame_duration,
            frames_per_file=frames_per_file)
        for pad in src.sinkpads:
            if channel_comment is not None:
                pad.set_property("comment", channel_comment)
            pad.set_property("pad-type", "FrProcData")
        pipeparts.mkframecppfilesink(pipeline,
                                     src,
                                     frame_type="%s_%s" %
                                     (instrument, description),
                                     path=output_path)
Example #3
0
def build_pipeline(pipeline,
                   data_source_info,
                   output_path=tempfile.gettempdir(),
                   description="TMPFILE_DELETE_ME",
                   channel_comment=None,
                   frame_duration=1,
                   frames_per_file=64,
                   verbose=False):

    channels = list(data_source_info.channel_dict.keys())

    #
    # retrieve auxiliary channels
    #

    # FIXME: turning off verbosity since this causes naming conflict with multiple progressreport elements, since they don't have unique identifiers.
    #        should really be using URI handling for this, but that's a separate issue altogether
    src = snaxparts.mkmultisrc(pipeline,
                               data_source_info,
                               channels,
                               verbose=False)

    #
    # pack into frame files for output
    #

    src = pipeparts.mkframecppchannelmux(
        pipeline, {channel: src[channel]
                   for channel in channels},
        frame_duration=frame_duration,
        frames_per_file=frames_per_file)
    for pad in src.sinkpads:
        if channel_comment is not None:
            pad.set_property("comment", channel_comment)
        pad.set_property("pad-type", "FrProcData")
    pipeparts.mkframecppfilesink(pipeline,
                                 src,
                                 frame_type="%s_%s" %
                                 (data_source_info.instrument, description),
                                 path=output_path)
Example #4
0
    try:
        os.makedirs(options.output_path)
    except Exception as e:
        print "Failed with %s" % e

    # Inject tags.  The framecpp_filesink element uses the tags to figure
    # out the output filename.
    print "Setting tag instrument: %s" % options.instrument
    tagInj = pipeparts.mktaginject(
        pipeline, mux, "instrument=%s,channel-name=%s" %
        (options.instrument, options.channel_name))

    path = options.output_path
    if path:
        fs = pipeparts.mkframecppfilesink(pipeline,
                                          tagInj,
                                          frame_type=options.frame_type,
                                          path=options.output_path)
    else:
        fs = pipeparts.mkframecppfilesink(pipeline,
                                          mux,
                                          frame_type=options.frame_type)
elif options.output_type == "tcp":
    # NB: like the appsrc, the tcp client sink does not use the 'blocksize' property.
    # It is just hanging around because it is inherited
    # gstdataprotocol serializes and sends the caps first. Then serializes and
    # sends the buffers. Less work for us.

    # XXX Sadness. The capsfilter is not "gap-aware". So the gap flag will be unset.
    mux = pipeparts.mkcapsfilter(pipeline,
                                 mux,
                                 caps="application/x-igwd-frame,framed=true")
# Final destination.
if options.output_type == "files":
    try:
        os.makedirs(options.output_path)
    except Exception as e:
        print "Failed with %s" % e

    # Inject tags.  The framecpp_filesink element uses the tags to figure
    # out the output filename.
    print "Setting tag instrument: %s" % options.instrument
    tagInj = pipeparts.mktaginject(pipeline, mux, 
        "instrument=%s,channel-name=%s" % (options.instrument, options.channel_name))

    path = options.output_path
    if path:
        fs = pipeparts.mkframecppfilesink(pipeline, tagInj, 
            frame_type = options.frame_type, path = options.output_path)
    else:
        fs = pipeparts.mkframecppfilesink(pipeline, mux, 
            frame_type = options.frame_type)
elif options.output_type == "tcp":
    # NB: like the appsrc, the tcp client sink does not use the 'blocksize' property. 
    # It is just hanging around because it is inherited
    # gstdataprotocol serializes and sends the caps first. Then serializes and 
    # sends the buffers. Less work for us.

    # XXX Sadness. The capsfilter is not "gap-aware". So the gap flag will be unset.
    mux = pipeparts.mkcapsfilter(pipeline,mux,caps="application/x-igwd-frame,framed=true")
    tcpclientsink = pipeparts.mkgeneric(pipeline, mux, "tcpclientsink")
    tcpclientsink.set_property("protocol", "GST_TCP_PROTOCOL_GDP")
    tcpclientsink.set_property("port", options.port)
    tcpclientsink.set_property("sync", False)