worker_processes auto;
rtmp_auto_push on;
events {}
rtmp {
    server {
        listen 1935;
        #listen [::]:1935 ipv6only=on;

        chunk_size 4096;


        application studiocam {

            live on;
            record off;

            allow publish all;
            allow play all;

#            exec_static /usr/bin/avconv -f v4l2 -i /dev/video0 -c:v libx264 -an -f flv rtmp://127.0.0.1:1935/studiocam/live;

        }


        application  hdmi {
            live on;
            record off;

            allow publish 192.168.2.0/24;
            deny publish all;

            # record hdmi
            # push 192.168.1.9:1935/ispoogemedia/hdmi;
        }



        application  cam {
            live on;
            record off;

            allow publish 192.168.1.0/24;
            deny publish all;
        }



        # monitor rtmp
        application record {
            live on;

            allow publish 127.0.0.0/24;
            deny publish all;
            deny play all;

            record all;
            record_path /tmp/rec;
            record_suffix _%Y-%m-%d_%H-%M-%S.flv;
            record_lock on;
        }


        application hls {
            live on;

            allow publish 127.0.0.0/8;
            deny publish all;
            allow play all;

#            pull rtmp://127.0.0.1:1935/ispoogedaily/ispoogedaily name=ispooge_com_hls live=1 static=1;

            hls on;
            hls_path /tmp/hls/ispooge.com;
            hls_fragment 500ms;
            hls_playlist_length 3s;
#            hls_fragment_naming_granularity 1s;

            hls_continuous off;
            hls_nested on;
            hls_cleanup off;
            hls_fragment_naming system;
            hls_fragment_slicing aligned;
            hls_type live;
        }

        # push to monitoring, push to recording


        application  ispoogedaily {
            live on;
            record off;

            allow publish 127.0.0.0/8;
            deny publish all;

            allow play all;
        }

        application ispoogedaily_local {
            live on;

            allow publish 127.0.0.0/8;
            allow publish 192.168.1.2;
            allow publish 192.168.1.3;
            deny publish all;
            deny play all;

            push rtmp://127.0.0.1:1935/ispoogedaily/ispoogedaily live=1;
            push rtmp://127.0.0.1:1935/record/ispoogedaily live=1;


            push rtmp://127.0.0.1:1935/hls/ispoogedaily name=ispoogedaily live=1;
        }


        # push to upstream services, including ispooge media
        application  ispoogedaily_live {
            live on;

            allow publish 127.0.0.0/8;
            allow publish 192.168.1.2;
            allow publish 192.168.1.3;

            deny publish all;
#            deny play all;

            push rtmp://127.0.0.1:1935/ispoogedaily_local/ispoogedaily_live;
#            push rtmp://live-api.facebook.com:80/rtmp/_?ds=_;

            # Periscope
            #push rtmp://ca.pscp.tv:80/x/_;


            # YT LIVE
            push rtmp://a.rtmp.youtube.com/live2/_ live=1;

            # YT EVENT
            # push rtmp://a.rtmp.youtube.com/live2/_;
        }





    }
}