Beispiel #1
0
func sample_trans(vsw *libvsw.Vsw, src1, src2 int) {
	log.Printf("sample_trans: Cut to input %d.\n", src1)
	vsw.Cut(src1)
	time.Sleep(3 * time.Second)
	rate := 1000
	log.Printf("sample_trans: Mix to input %d at rate %d msec.\n", src2, rate)
	vsw.Mix(rate, src2)
	time.Sleep(3 * time.Second)
}
Beispiel #2
0
func loop(vsw *libvsw.Vsw, pa Params, notify chan Params) {
	index := 0
	for {
		select {
		case pa = <-notify:
			log.Printf("got from chan\n")
			saveParams(pa)
			if pa.StartLiveBroadcast {
				vsw.ChangeLiveBroadcastState(1)
			} else {
				vsw.ChangeLiveBroadcastState(0)
			}
			if pa.UploadStillPicture {
				vsw.UploadFile(pa.Picture)
			}
		case <-time.After(time.Second * time.Duration(pa.Interval)):
			log.Printf("periodic timer\n")
		}
		index = (index + 1) % 4
		i := 0
		for ; i < 4; i++ {
			if pa.Input[i] == true {
				break
			}
		}
		if i == 4 {
			// no input checked
			pa.Interval = 1000000
			continue
		}
		for pa.Input[index] == false {
			index = (index + 1) % 4
		}
		switch pa.Trans & 0xff {
		case 0:
			vsw.Cut(index + 1)
		case 1:
			vsw.Mix(pa.Rate, index+1)
		case 2:
			vsw.Dip(pa.Rate, index+1, ((pa.Trans>>8)&3)+1)
		case 255:
			vsw.Wipe(pa.Rate, index+1, random(0, libvsw.WIPE_TYPE_NUM-1))
		default:
			vsw.Wipe(pa.Rate, index+1, pa.Trans-libvsw.TRANSITION_TYPE_WIPE)
		}
	}
}