예제 #1
0
async def update_mixer(request, id):
    if id not in request['session'].mixers or request['session'].mixers[id] is None:
        return _user_error_response('No such mixer ID')
    if 'state' in request.json:
        request.json['state'] = state_string_to_constant(request.json['state'])
        if not request.json['state']:
            return _user_error_response('Invalid state')
    request['session'].mixers[id].update(request.json)
    return _status_ok_response()
예제 #2
0
async def update_mixer(request, id):
    session = brave.session.get_session()
    if not request.json:
        return _invalid_json_response()
    if id not in session.mixers or session.mixers[id] is None:
        return _user_error_response('No such mixer ID')
    if 'state' in request.json:
        request.json['state'] = state_string_to_constant(request.json['state'])
        if not request.json['state']:
            return _user_error_response('Invalid state')
    try:
        session.mixers[id].update(request.json)
    except brave.exceptions.InvalidConfiguration as e:
        return _invalid_configuration_response(e)
    return _status_ok_response()
예제 #3
0
 def __consider_initial_state(self, new_state):
     '''
     If the user has requested an initial state for this element, this method sets it at the correct time.
     '''
     should_go_to_initial_state = new_state == Gst.State.READY and 'initial_state' in self.props and \
         (not hasattr(self, 'initial_state_initiated') or not self.initial_state_initiated)
     if should_go_to_initial_state:
         self.logger.debug(
             'Now at READY state, time to set initial state of "%s"' %
             self.props['initial_state'])
         state_to_change_to = state_string_to_constant(
             self.props['initial_state'])
         if state_to_change_to:
             self.set_state(state_to_change_to)
         else:
             self.logger.warn(
                 'Unable to set to initial unknown state "%s"' %
                 self.props['initial_state'])
         self.initial_state_initiated = True
예제 #4
0
    def state(self, new_state):
        '''
        Allows the state to be set. Can be either a string (e.g. 'READY') or the Gst constant.
        '''
        if new_state is None:
            self._desired_state = None
            return

        if new_state not in [
                Gst.State.PLAYING, Gst.State.PAUSED, Gst.State.READY,
                Gst.State.NULL
        ]:
            converted_state = state_string_to_constant(new_state)
            if not converted_state:
                raise brave.exceptions.InvalidConfiguration(
                    'Invalid state "%s"' % new_state)
            else:
                new_state = converted_state

        self.desired_state = new_state

        if self.setup_complete:
            self._consider_changing_state()
예제 #5
0
def _validate_state(request):
    if 'state' in request.json:
        request.json['state'] = state_string_to_constant(request.json['state'])
        if not request.json['state']:
            raise InvalidUsage(
                'Invalid state. Must be PLAYING, PAUSED, READY or NULL.')