2011/2/28 Ian Bonham <[email protected]>:
> Hi David,

Howdy all!

> >From what I can figure out, what you're suggesting is the dump.start
> and dump.stop commands inside a source?
> Thats a possibility, but my sources can switch. In some instances I
> will be mainly collecting from ALSA input, and on a failure of that
> source I switch to a local .pls.
> Using the dump function, I am thinking that the source is just written
> out as it comes in, so coming from ALSA I'd just be writing out raw
> PCM data, but the local .pls might be an any format?
>
> What I need to do is make sure that the files are always saved in MP3,
> so I need to transcode the stream into MP3 and then I was thinking of
> using output.file to write the files out. output.file would then have
> to be switchable. The files we log need to be in MP3 because there are
> some shows that are recorded and edited for re-play at a later date,
> and some made available on the web site for 'listen again'.
>
> Is it possible to switch the output.file somehow? I can't get my head
> around the logic at the moment (it is early in the morning!!).
> If anyone could give a simple example I'm sure I can figure out the rest.

(warning: most of the following code has not been tested. I may likely
have typos :) )

Maybe I've missed something but I think there is a "simple" solution
to your problem.

If I get it right, you want to record the main source, that is the
final stream broadcasted to your listeners.
Also, the time to turn on/off recording may change so it should be dynamic.

So in this case, first let me examplain the basic idea.
Originally, you have something like that:

s = (...)

output.XXX(...,s)

where s is the final source sent to the users.
There you can insert two things: an operator that create a new source
s' that will be available only when you want to record s and a file
output. So:

s = (...)

s' = available_when_record(s)

output.file(%mp3,"/path/to/dump.mp3",fallible=true,s')

output.XXX(...,s)

Now let's work on the available_when_record part. I think you have two
main options:
 (1) A regular poll coming from liquidsoap
 (2) An external script operated on your side to turn on/off recording

In case (1), you write a script that tells liquidsoap when to start
the recording source and create a switch that calls that script
regularly (the script has to be light!). This gives:

def available_when_record(s) =
  # Define a function that returns true when
  # the new source should be available
  def is_ready() =
    # Call external script
    ans = list.hd(get_process_lines("/path/to/ask.script"))
    # True if output is "1"
    ans == "1"
  end

  # Now use this function to create a conditional switch
  switch([(is_ready,s)])
end

This polling will be VERY regular. If the script is too heavy, you may
be able to code an alternative polling using add_timeout where you can
can control the frequency of the polling. but the overall idea is the
same.

In case (2), you define a source is activated by an external command.
For instance a telnet command. Let's see how we can sketch that.. The
following code is for liquidsoap 1.0beta and +

# Register a global is_ready
is_ready = ref false

# Register telnet commands to toggle is_ready
server.register(namespace="dump",
                description="Start dumping.",
                usage="dump.start",
                "start",
                fun (_) ->  begin is_ready := true "Done!" end)
server.register(namespace="dump",
                description="Stop dumping.",
                usage="dump.stop",
                "stop",
                fun (_) -> begin is_ready := false "Done!" end)

You may as well in liquidsoap 1.0SVN register HTTP harbor commands for
that and use an AJAX/GET/POST interface..

Finally, you use is_ready in a switch as before:

def available_when_record(s) =
  # Define a function that returns true when
  # the new source should be available
  def is_ready() =
    !is_ready
  end

  # Now use this function to create a conditional switch
  switch([(is_ready,s)])
end

I think that will be enough for today... In the future you may also
want to control the location of the recording file, which may also be
done using these techniques..

Let us know if you have more questions!
Romain

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to