Ejemplo n.º 1
0
function _pluginChooseRecOrPlay($cid, $gmt = -1, $isVideo = true)
{
    // Please note that all global variables
    // are wiped out! Therefore we have to instantiate
    // a local instance here ....
    // don't break your head about login / logout at kartina!
    // we will load the cookie from file so no authentication
    // is needed here ... we also don't need username and PW ...
    $tmpKartAPI = new kartinaAPI();
    // load cookie ...
    $tmpKartAPI->loadCookie();
    $retMediaItems = array();
    if (($channelList = $tmpKartAPI->getChannelListXml()) !== FALSE) {
        // get channel info ...
        $domChanList = new DOMDocument();
        $domChanList->loadXML($channelList);
        $xpchan = new DOMXpath($domChanList);
        $chanitem = $xpchan->query("/response/groups/item/channels/item[id='" . $cid . "']");
        $chan = $chanitem->item(0);
        // there is only one such item ...
        $recname = $xpchan->query("name", $chan)->item(0)->nodeValue;
        $hasarch = (int) $xpchan->query("have_archive", $chan)->item(0)->nodeValue;
        /////////////////////////////////////////////////////////////////////////////
        // add epg info first ...
        // epg data array ...
        $epg_data = array('cid' => $cid, 'gmt' => $gmt);
        $epg_data_query = http_build_query($epg_data);
        // epg info image ...
        $retMediaItems[] = array('id' => LOC_KARTINA_UMSP . "/kartina?" . urlencode(md5($epg_data_query)), 'dc:title' => "Информация", 'upnp:class' => "object.item.imageitem", 'res' => LOC_KARTINA_URL . "/epg2img.php?" . $epg_data_query, 'protocolInfo' => "http-get:*:image/JPEG:DLNA.ORG_PN=JPEG_LRG", 'resolution' => "1920x1080", 'colorDepth' => 24);
        /////////////////////////////////////////////////////////////////////////////
        // play item ...
        // if we have an archive, we can jump backward and forward.
        // To make this accessable, create a new play folder ...
        if ($gmt != -1 && $hasarch && inArchive($gmt, $tmpKartAPI->getLastServerTime())) {
            $data = array('action' => 'play_rewind', 'gmt' => $gmt, 'is_video' => $isVideo, 'cid' => $cid);
            simpleLog(__FUNCTION__ . "():" . __LINE__ . " Add Play / Rewind Item (cid=" . $cid . ", gmt=" . $gmt . ", is_video=" . $isVideo . ")");
            $dataString = http_build_query($data, "", "&");
            $retMediaItems[] = array('id' => LOC_KARTINA_UMSP . "/kartina?" . $dataString, 'dc:title' => "Просмотр / Перемотка", 'upnp:class' => 'object.container', 'upnp:album_art' => LOC_KARTINA_URL . "/images/play.png");
        } else {
            if ($gmt == -1) {
                // live stream doesn't allow forward / backward jumping ...
                // play data array ...
                $play_data = array('cid' => $cid, 'gmt' => $gmt, 'is_video' => $isVideo, 'dorec' => false);
                simpleLog(__FUNCTION__ . "():" . __LINE__ . " Add Play Item (cid=" . $cid . ", gmt=" . $gmt . ", is_video=" . $isVideo . ", dorec=false)");
                $play_data_query = http_build_query($play_data);
                // add play item ...
                $retMediaItems[] = array('id' => LOC_KARTINA_UMSP . "/kartina?" . urlencode(md5($play_data_query)), 'dc:title' => "Просмотр", 'upnp:class' => $isVideo ? "object.item.videoitem" : "object.item.audioitem", 'res' => LOC_KARTINA_URL . "/http-stream-recorder.php?" . $play_data_query, 'protocolInfo' => "http-get:*:*:*", 'upnp:album_art' => LOC_KARTINA_URL . "/images/play.png");
            }
        }
        /////////////////////////////////////////////////////////////////////////////
        // record entry ...
        if ($gmt == -1 || $hasarch && inArchive($gmt, $tmpKartAPI->getLastServerTime())) {
            // replace some funky characters which could lead to problems ...
            $recname = str_replace(" ", "_", $recname) . "-";
            $recname = str_replace("/", "-", $recname);
            $recname = str_replace("\\", "", $recname);
            // add date ...
            $recname .= $gmt === -1 ? date("d.m.y-H_i", $tmpKartAPI->getLastServerTime()) : date("d.m.y-H_i", $gmt);
            // rec data array ...
            $rec_data = array('cid' => $cid, 'gmt' => $gmt, 'is_video' => $isVideo, 'dorec' => true, 'recfile' => $recname);
            simpleLog(__FUNCTION__ . "():" . __LINE__ . " Add Rec Item (cid=" . $cid . ", gmt=" . $gmt . ", is_video=" . $isVideo . ", dorec=true, " . "recfile=" . $recname . ")");
            $rec_data_query = http_build_query($rec_data);
            // add record item ...
            $retMediaItems[] = array('id' => LOC_KARTINA_UMSP . "/kartina?" . urlencode(md5($rec_data_query)), 'dc:title' => "Запись в "" . $recname . ".ts"", 'upnp:class' => $isVideo ? "object.item.videoitem" : "object.item.audioitem", 'res' => LOC_KARTINA_URL . "/http-stream-recorder.php?" . $rec_data_query, 'protocolInfo' => "http-get:*:*:*", 'upnp:album_art' => LOC_KARTINA_URL . "/images/record.png");
        }
    }
    return $retMediaItems;
}
Ejemplo n.º 2
0
function wec_kartinatv_getChans()
{
    $api = new kartinaAPI();
    $api->loadCookie();
    // fill in availabe values ...
    $chanarr = $api->getChannelList();
    $chans = array();
    for ($i = 0; $i < count($chanarr); $i++) {
        $chans[] = $chanarr[$i]['name'];
    }
    return $chans;
}