<commit_before># -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4

# Flumotion - a streaming media server
# Copyright (C) 2004,2005,2006,2007,2008,2009 Fluendo, S.L.
# Copyright (C) 2010,2011 Flumotion Services, S.A.
# All rights reserved.
#
# This file may be distributed and/or modified under the terms of
# the GNU Lesser General Public License version 2.1 as published by
# the Free Software Foundation.
# This file is distributed without any warranty; without even the implied
# warranty of merchantability or fitness for a particular purpose.
# See "LICENSE.LGPL" in the source distribution for more information.
#
# Headers in this file shall remain intact.

import gst
import urlparse

from twisted.internet import reactor

from flumotion.common import gstreamer
from flumotion.common.i18n import gettexter
from flumotion.component.base import http
from flumotion.component.component import moods
from flumotion.component.common.streamer.fragmentedstreamer import\
        FragmentedStreamer, Stats
from flumotion.component.consumers.hlsstreamer.resources import \
        HTTPLiveStreamingResource
from flumotion.component.consumers.hlsstreamer.hlsring import HLSRing
from flumotion.component.consumers.hlsstreamer import hlssink

__all__ = ['HLSStreamer']
__version__ = ""
T_ = gettexter()


SUPPORTED_FORMATS = {"video/mpegts": ("video/mpegts", "video/mpegts", "ts"),
                     "video/webm": ("video/webm", "video/webm", "webm")}


class HLSStreamer(FragmentedStreamer, Stats):
    DEFAULT_SESSION_TIMEOUT = 30
    DEFAULT_FRAGMENT_PREFIX = 'fragment'
    DEFAULT_MAIN_PLAYLIST = 'main.m3u8'
    DEFAULT_STREAM_PLAYLIST = 'stream.m3u8'
    DEFAULT_STREAM_BITRATE = 300000
    DEFAULT_KEYFRAMES_PER_SEGMENT = 10

    logCategory = 'hls-streamer'

    _mime_type = None
    _content_type = None
    _stream_setup = False

    def init(self):
        self.debug("HTTP live streamer initialising")
        self.hlsring = None

    def get_mime(self):
        return self._mime_type

    def get_content_type(self):
        return self._content_type

    def get_pipeline_string(self, properties):
        # Check of the hlssink is available or use the python one
        if not gstreamer.element_factory_exists('hlssink'):
            hlssink.register()
        return "hlssink name=sink sync=false"

    def configure_auth_and_resource(self):
        self.httpauth = http.HTTPAuthentication(self)
        self.resource = HTTPLiveStreamingResource(self, self.httpauth,
                self.secret_key, self.session_timeout)

    def getRing(self):
        return self.hlsring

    def configure_pipeline(self, pipeline, props):
        self.hlsring = HLSRing(
            props.get('main-playlist', self.DEFAULT_MAIN_PLAYLIST),
            props.get('stream-playlist', self.DEFAULT_STREAM_PLAYLIST),
            props.get('stream-bitrate', self.DEFAULT_STREAM_BITRATE),
            self.description,
            props.get('fragment-prefix', self.DEFAULT_FRAGMENT_PREFIX),
            props.get('new-fragment-tolerance', 0),
            props.get('max-window', self.DEFAULT_MAX_WINDOW),<commit_msg>Don't use the C hlssink element, which is not mature enough.<commit_after># -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4

# Flumotion - a streaming media server
# Copyright (C) 2004,2005,2006,2007,2008,2009 Fluendo, S.L.
# Copyright (C) 2010,2011 Flumotion Services, S.A.
# All rights reserved.
#
# This file may be distributed and/or modified under the terms of
# the GNU Lesser General Public License version 2.1 as published by
# the Free Software Foundation.
# This file is distributed without any warranty; without even the implied
# warranty of merchantability or fitness for a particular purpose.
# See "LICENSE.LGPL" in the source distribution for more information.
#
# Headers in this file shall remain intact.

import gst
import urlparse

from twisted.internet import reactor

from flumotion.common import gstreamer
from flumotion.common.i18n import gettexter
from flumotion.component.base import http
from flumotion.component.component import moods
from flumotion.component.common.streamer.fragmentedstreamer import\
        FragmentedStreamer, Stats
from flumotion.component.consumers.hlsstreamer.resources import \
        HTTPLiveStreamingResource
from flumotion.component.consumers.hlsstreamer.hlsring import HLSRing
from flumotion.component.consumers.hlsstreamer import hlssink

__all__ = ['HLSStreamer']
__version__ = ""
T_ = gettexter()


SUPPORTED_FORMATS = {"video/mpegts": ("video/mpegts", "video/mpegts", "ts"),
                     "video/webm": ("video/webm", "video/webm", "webm")}


class HLSStreamer(FragmentedStreamer, Stats):
    DEFAULT_SESSION_TIMEOUT = 30
    DEFAULT_FRAGMENT_PREFIX = 'fragment'
    DEFAULT_MAIN_PLAYLIST = 'main.m3u8'
    DEFAULT_STREAM_PLAYLIST = 'stream.m3u8'
    DEFAULT_STREAM_BITRATE = 300000
    DEFAULT_KEYFRAMES_PER_SEGMENT = 10

    logCategory = 'hls-streamer'

    _mime_type = None
    _content_type = None
    _stream_setup = False

    def init(self):
        self.debug("HTTP live streamer initialising")
        self.hlsring = None

    def get_mime(self):
        return self._mime_type

    def get_content_type(self):
        return self._content_type

    def get_pipeline_string(self, properties):
        # Always use the python element for now. The C element will be used
        # when it is mature enough.
        # if not gstreamer.element_factory_exists('hlssink'):
        hlssink.register()
        return "hlssink name=sink sync=false"

    def configure_auth_and_resource(self):
        self.httpauth = http.HTTPAuthentication(self)
        self.resource = HTTPLiveStreamingResource(self, self.httpauth,
                self.secret_key, self.session_timeout)

    def getRing(self):
        return self.hlsring

    def configure_pipeline(self, pipeline, props):
        self.hlsring = HLSRing(
            props.get('main-playlist', self.DEFAULT_MAIN_PLAYLIST),
            props.get('stream-playlist', self.DEFAULT_STREAM_PLAYLIST),
            props.get('stream-bitrate', self.DEFAULT_STREAM_BITRATE),
            self.description,
            props.get('fragment-prefix', self.DEFAULT_FRAGMENT_PREFIX),
            props.get('new-fragment-tolerance', 0),
            props.get('max-window', self.DEFAULT_MAX_WINDOW),
{'fraction_non_alphanumeric': 0.0900458933375534, 'fraction_numerical': 0.017091311916442475, 'mean_word_length': 3.5763939174511226, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '674100', 'n_tokens_mistral': 2013, 'n_tokens_neox': 1895, 'n_words': 482}