예제 #1
0
    def add_cod_encode(self):
        server = current_user.get_current_server()
        if server:
            stream = server.make_cod_encode_stream()
            form = CodEncodeStreamForm(obj=stream)
            if request.method == 'POST' and form.validate_on_submit():
                new_entry = form.update_entry(stream)
                new_entry.save()
                server.add_stream(new_entry)
                return jsonify(status='ok'), 200

            return render_template('stream/cod_encode/add.html', form=form,
                                   feedback_dir=stream.generate_feedback_dir())
        return jsonify(status='failed'), 404
예제 #2
0
    def edit(self, sid):
        server = current_user.get_current_server()
        if server:
            stream = server.find_stream_by_id(sid)
            if stream:
                type = stream.get_type()
                if type == constants.StreamType.PROXY:
                    form = ProxyStreamForm(obj=stream)

                    if request.method == 'POST' and form.validate_on_submit():
                        stream = form.update_entry(stream)
                        server.update_stream(stream)
                        return jsonify(status='ok'), 200

                    return render_template('stream/proxy/edit.html', form=form)
                elif type == constants.StreamType.RELAY:
                    form = RelayStreamForm(obj=stream)

                    if request.method == 'POST' and form.validate_on_submit():
                        stream = form.update_entry(stream)
                        server.update_stream(stream)
                        return jsonify(status='ok'), 200

                    return render_template(
                        'stream/relay/edit.html',
                        form=form,
                        feedback_dir=stream.generate_feedback_dir())
                elif type == constants.StreamType.ENCODE:
                    form = EncodeStreamForm(obj=stream)

                    if request.method == 'POST' and form.validate_on_submit():
                        stream = form.update_entry(stream)
                        server.update_stream(stream)
                        return jsonify(status='ok'), 200

                    return render_template(
                        'stream/encode/edit.html',
                        form=form,
                        feedback_dir=stream.generate_feedback_dir())
                elif type == constants.StreamType.TIMESHIFT_RECORDER:
                    form = TimeshiftRecorderStreamForm(obj=stream)

                    if request.method == 'POST':  # FIXME form.validate_on_submit()
                        stream = form.update_entry(stream)
                        server.update_stream(stream)
                        return jsonify(status='ok'), 200

                    return render_template(
                        'stream/timeshift_recorder/edit.html',
                        form=form,
                        feedback_dir=stream.generate_feedback_dir(),
                        timeshift_dir=stream.generate_timeshift_dir())
                elif type == constants.StreamType.CATCHUP:
                    form = CatchupStreamForm(obj=stream)

                    if request.method == 'POST':  # FIXME form.validate_on_submit()
                        stream = form.update_entry(stream)
                        server.update_stream(stream)
                        return jsonify(status='ok'), 200

                    return render_template(
                        'stream/catchup/edit.html',
                        form=form,
                        feedback_dir=stream.generate_feedback_dir(),
                        timeshift_dir=stream.generate_timeshift_dir())
                elif type == constants.StreamType.TIMESHIFT_PLAYER:
                    form = TimeshiftPlayerStreamForm(obj=stream)

                    if request.method == 'POST' and form.validate_on_submit():
                        stream = form.update_entry(stream)
                        server.update_stream(stream)
                        return jsonify(status='ok'), 200

                    return render_template(
                        'stream/timeshift_player/edit.html',
                        form=form,
                        feedback_dir=stream.generate_feedback_dir())
                elif type == constants.StreamType.TEST_LIFE:
                    form = TestLifeStreamForm(obj=stream)

                    if request.method == 'POST':  # FIXME form.validate_on_submit()
                        stream = form.update_entry(stream)
                        server.update_stream(stream)
                        return jsonify(status='ok'), 200

                    return render_template(
                        'stream/test_life/edit.html',
                        form=form,
                        feedback_dir=stream.generate_feedback_dir())
                elif type == constants.StreamType.VOD_RELAY:
                    form = VodRelayStreamForm(obj=stream)

                    if request.method == 'POST' and form.validate_on_submit():
                        stream = form.update_entry(stream)
                        server.update_stream(stream)
                        return jsonify(status='ok'), 200

                    return render_template(
                        'stream/vod_relay/edit.html',
                        form=form,
                        feedback_dir=stream.generate_feedback_dir())
                elif type == constants.StreamType.VOD_ENCODE:
                    form = VodEncodeStreamForm(obj=stream)

                    if request.method == 'POST' and form.validate_on_submit():
                        stream = form.update_entry(stream)
                        server.update_stream(stream)
                        return jsonify(status='ok'), 200

                    return render_template(
                        'stream/vod_encode/edit.html',
                        form=form,
                        feedback_dir=stream.generate_feedback_dir())
                elif type == constants.StreamType.COD_RELAY:
                    form = CodRelayStreamForm(obj=stream)

                    if request.method == 'POST' and form.validate_on_submit():
                        stream = form.update_entry(stream)
                        server.update_stream(stream)
                        return jsonify(status='ok'), 200

                    return render_template(
                        'stream/cod_relay/edit.html',
                        form=form,
                        feedback_dir=stream.generate_feedback_dir())
                elif type == constants.StreamType.COD_ENCODE:
                    form = CodEncodeStreamForm(obj=stream)

                    if request.method == 'POST' and form.validate_on_submit():
                        stream = form.update_entry(stream)
                        server.update_stream(stream)
                        return jsonify(status='ok'), 200

                    return render_template(
                        'stream/cod_encode/edit.html',
                        form=form,
                        feedback_dir=stream.generate_feedback_dir())

        return jsonify(status='failed'), 404