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 sample_wipe(vsw *libvsw.Vsw, src1, src2 int) {
	log.Printf("wipeTest src1=%d src2=%d\n", src1, src2)
	vsw.Cut(src1)

	for wipe_type := 0; wipe_type < libvsw.WIPE_TYPE_NUM; wipe_type++ {
		log.Printf("wipe_type=%d\n", wipe_type)
		vsw.Wipe(rate, src2, wipe_type)
		time.Sleep((rate + wait) * time.Millisecond)
		vsw.Wipe(rate, src1, wipe_type)
		time.Sleep((rate + wait) * time.Millisecond)
	}
}
Beispiel #3
0
func sample_status(vsw *libvsw.Vsw) {
	c := vsw.RequestSwitcherStatus()
	c2 := vsw.RequestRecordingResult()
	// You get other channels by vsw.Request* in a similar way.

	tick := time.Tick(10 * time.Second)
	for {
		select {
		case <-tick:
			// Send heart beat every 10 seconds
			vsw.HeartBeat()
			log.Printf("sample_status: HeartBeat!\n")
		case ss := <-c:
			log.Printf("sample_status: %#v\n", ss)
		case ss := <-c2:
			log.Printf("sample_status: %#v\n", ss)
		}
	}
}
Beispiel #4
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)
		}
	}
}
Beispiel #5
0
func sample_pinp(vsw *libvsw.Vsw, mainSrc, subSrc int) {
	vsw.Cut(mainSrc)
	vsw.CutSub(0) // Erase sub screen
	// Scale quarter size, No cropping
	vsw.PinpGeometry(0, 0, 65536/4, 65536/4, 0, 0, 65536, 65536)
	vsw.PinpBorder(0x00ff00ff, 4)
	vsw.SetSubMode(libvsw.SUB_MODE_PINP)
	rate := 1000
	vsw.MixSub(rate, subSrc) // Show sub screen slowly
	time.Sleep(time.Duration(rate) * time.Millisecond)
	for {
		for i := 1; i < 4; i++ {
			time.Sleep(time.Duration(rate) * time.Millisecond)
			vsw.PinpGeometry(65536/4*i, 0, 65536/4, 65536/4, 0, 0, 65536, 65536)
		}
		for i := 1; i < 4; i++ {
			time.Sleep(time.Duration(rate) * time.Millisecond)
			vsw.PinpGeometry(65536/4*3, 65536/4*i, 65536/4, 65536/4, 0, 0, 65536, 65536)
		}
		for i := 2; i >= 0; i-- {
			time.Sleep(time.Duration(rate) * time.Millisecond)
			vsw.PinpGeometry(65536/4*i, 65536/4*3, 65536/4, 65536/4, 0, 0, 65536, 65536)
		}
		for i := 2; i >= 0; i-- {
			time.Sleep(time.Duration(rate) * time.Millisecond)
			vsw.PinpGeometry(65536/4*0, 65536/4*i, 65536/4, 65536/4, 0, 0, 65536, 65536)
		}
	}
}
func sample_chromakey(vsw *libvsw.Vsw) {
	wait := 8000
	vsw.CutSub(0)
	vsw.Cut(1)

	// You have to insert a writable SD card to LiveWedge.
	vsw.UploadFile("greenback.jpg")
	vsw.SetChromaKey(libvsw.CHROMA_KEY_GREEN)
	vsw.CutSub(4)
	time.Sleep(time.Duration(wait) * time.Millisecond)
	vsw.CutSub(0)

	vsw.UploadFile("blueback.jpg")
	vsw.SetChromaKey(libvsw.CHROMA_KEY_BLUE)
	vsw.MixSub(2000, 4)
	time.Sleep(time.Duration(wait) * time.Millisecond)
	vsw.MixSub(2000, 0)

	vsw.UploadFile("purpleback.jpg")
	vsw.SetChromaKey(libvsw.CHROMA_KEY_PURPLE)
	vsw.CutSub(4)
	time.Sleep(time.Duration(wait) * time.Millisecond)
	vsw.CutSub(0)

	vsw.UploadFile("redback.jpg")
	vsw.SetChromaKey(libvsw.CHROMA_KEY_RED)
	vsw.MixSub(2000, 4)
	time.Sleep(time.Duration(wait) * time.Millisecond)
	vsw.MixSub(2000, 0)
}