On Sun, 2012-04-08 at 18:10 +1000, Liz wrote:
> 1. I managed to get Freevo to tune the hdhomerun and dump the stream
> to a buffer on the HDD.
> I didn't get anything on the screen to watch, I didn't get any audio.
> It just says "Tuning [channel]".
> I can't decipher to recorded stream with vlc, mplayer or xine.
Nope you haven't not yet, the fact that you are stilling seeing the 'Tuning' 
message means that no packets have yet been captured.
See my other mail on hopefully solving this..

> 2. I tried recording with the generic record plugin but it doesn't send
> a tuning sequence of commands.
> I get a fxd file created but not even an empty file for the record.
> I've tried a few commands for vlc and mplayer that might have worked.

With the generic record plugin you need to specify a script to run that
will do the recording. The script gets passed a whole load of parameters
(configured by local_conf.py). You need to in that script use the
hdhomerun config program to configure the device and then capture the
stream.

> 
> Anyone got any further suggestions??
> 

I've attached a knocked together a HDHomeRun recording plugin, drop this
into the freevo/tv/plugins directory under the python library directory
where freevo was installed (something
like /usr/local/lib/python2.7/dist-packages/freevo/tv/plugins).
Then use this plugin instead of the generic record plugin.
Hopefully it should do everything that is required to record from the
HDHomeRun. If it works I'll drop it into the main repo.

Cheers

Adam
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
# record.py - the Freevo DVBStreamer Recording module for tv
# -----------------------------------------------------------------------
# $Id$
#
# Notes:
#
# Only supports DVBStreamer instance on localhost.
#
# Todo:
#
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# ----------------------------------------------------------------------- */
import logging
logger = logging.getLogger("freevo.tv.plugins.hdhomerun")


import time
import os
import re
import copy
import sys
import threading
from socket import *

import config     # Configuration handler. reads config file.
import util
import childapp
import rc
import util.tv_util as tv_util

from tv.channels import FreevoChannels

from event import *
import plugin

DEBUG=config.DEBUG

class PluginInterface(plugin.Plugin):
    """
    HDHomeRun Recorder
    """

    def __init__(self):
        plugin.Plugin.__init__(self)
        logger.debug('HDHomeRun plugin starting')
        # register the DVBStreamer record
        plugin.register(Recorder(manager), plugin.RECORD)


###############################################################################
# Recorder
###############################################################################

class Recorder:
    """
    Class to record to file
    """

    def __init__(self):
        # Disable this plugin if not loaded by record_server.
        if sys.argv[0].find('recordserver') == -1:
            return

        self.fc = FreevoChannels()
        self.thread = Record_Thread()
        self.thread.setDaemon(1)
        self.thread.mode = 'idle'
        self.thread.start()


    def Record(self, rec_prog):
        """
        Start recording the specified program.
        """
        self.thread.prog = rec_prog
        self.thread.mode = 'record'
        self.thread.mode_flag.set()

    def Stop(self):
        """
        Stop recording.
        """
        self.thread.mode = 'stop'
        self.thread.mode_flag.set()


class Record_Thread(threading.Thread):
    """
    Thread class that actually does the recording.
    """

    def __init__(self):
        threading.Thread.__init__(self)
        self.fc = FreevoChannels()
        self.manager = manager
        self.mode = 'idle'
        self.mode_flag = threading.Event()
        self.prog = None
        self.app = None


    def run(self):
        """
        Thread loop.
        """
        while 1:
            if DEBUG: print('Record_Thread::run: mode=%s' % self.mode)
            if self.mode == 'idle':
                self.mode_flag.wait()
                self.mode_flag.clear()

            elif self.mode == 'record':
                rc.post_event(Event('RECORD_START', arg=self.prog))
                if DEBUG: print('Record_Thread::run: started recording')

                prog = self.prog
                filename = tv_util.getProgFilename(prog)
                vg = self.fc.getVideoGroup(prog.tunerid, False)
                adapter = vg.vdev
                seconds = prog.rec_duration

                id,  tuner = adapter.split(':', 2)
                freq, channel = prog.tunerid.split('.', 2)

                s = socket(type=SOCK_DGRAM)
                port = 1236
                s.bind(('', port))
                s.settimeout(0.5)
                ip_address = gethostbyname(gethostname())

                os.system('hdhomerun_config %s set /tuner%s/channel %s' % (id, tuner, freq))
                os.system('hdhomerun_config %s set /tuner%s/program %s' % (id, tuner, channel))
                os.system('hdhomerun_config %s set /tuner%s/target %s:%d' % (id, tuner, ip_address, port))

                try:
                    f = open(filename, 'wb')
                    # Select the channel and start streaming to the file.
                    end_time = time.time() + seconds
                    while (self.mode == 'record') and (time.time() < end_time):
                        try:
                            data,ip = s.recvfrom(1500)
                            f.write(data)
                        except socket.timeout:
                            pass

                    # Close the file
                    os.system('hdhomerun_config %s set /tuner%s/target none' % (id, tuner))
                    f.close()
                    s.close()
                except IOError:
                    pass

                rc.post_event(Event('RECORD_STOP', arg=self.prog))
                if DEBUG: print('Record_Thread::run: finished recording')

                self.mode = 'idle'
            else:
                self.mode = 'idle'
            time.sleep(0.5)
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Freevo-users mailing list
Freevo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-users

Reply via email to