# Path: src/vision/configuration.py
# class Configuration(object):
# class FKConfiguration(Configuration):
# class DeveloperConfiguration(Configuration):
#     def config_strings(self):
#     def config_tuples(self):


import logging
import os
from pathlib import Path
from vision.players.base_player import BasePlayer
from pycaspar import CasparCG
from ..configuration import configuration
video.

Protocol http://casparcg.com/wiki/CasparCG_2.1_AMCP_Protocol

We use layers 10 for the fallback screen, 50 for the video playout and
100 for the logo in the corner.

"""


MEDIA_LAYER = 50
BUG_LAYER = 100

class CasparCGPlayer(BasePlayer):
    def __init__(self, loop_filename):
        self.caspar = CasparCG('localhost')
        self.channel = self.caspar.channel(1)
        self.media_layer = self.channel.layer(MEDIA_LAYER)
        self.channel.clear()
        watermarkimage = 'stills/screenbug'
        self._play_file(watermarkimage, layer=self.channel.layer(BUG_LAYER), loop=True)

    def _play_file(self, filename, resume_offset=0, layer=None, loop=False):
        if layer is None:
            layer = self.media_layer

        if filename is not None:
            logging.debug('CasparCG is being asked to play filename %s', filename)

            if '/mnt/media' in filename:

# Path: src/vision/configuration.py
# class Configuration(object):
# class FKConfiguration(Configuration):
# class DeveloperConfiguration(Configuration):
#     def config_strings(self):
#     def config_tuples(self):


# Path: src/vision/players/casparcg_player.py
import logging
import os
from pathlib import Path
from vision.players.base_player import BasePlayer
from pycaspar import CasparCG
from ..configuration import configuration

video.

Protocol http://casparcg.com/wiki/CasparCG_2.1_AMCP_Protocol

We use layers 10 for the fallback screen, 50 for the video playout and
100 for the logo in the corner.

"""


MEDIA_LAYER = 50
BUG_LAYER = 100

class CasparCGPlayer(BasePlayer):
    def __init__(self, loop_filename):
        self.caspar = CasparCG('localhost')
        self.channel = self.caspar.channel(1)
        self.media_layer = self.channel.layer(MEDIA_LAYER)
        self.channel.clear()
        watermarkimage = 'stills/screenbug'
        self._play_file(watermarkimage, layer=self.channel.layer(BUG_LAYER), loop=True)

    def _play_file(self, filename, resume_offset=0, layer=None, loop=False):
        if layer is None:
            layer = self.media_layer

        if filename is not None:
            logging.debug('CasparCG is being asked to play filename %s', filename)

            if '/mnt/media' in filename:

                filename = '%s' % (Path(filename).relative_to(configuration.media_root),)