1 Star 0 Fork 0

bdqi/go-v4l2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
cast.go 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
Charles Iliya Krempeaux 提交于 2018-03-19 16:20 +08:00 . v4l2_framesize
package v4l2_framesize
import (
"fmt"
"unsafe"
)
const (
const_TYPE_DISCRETE = 1 // (V4L2_FRMSIZE_TYPE_DISCRETE)
const_TYPE_CONTINUOUS = 2 // (V4L2_FRMSIZE_TYPE_CONTINUOUS)
const_TYPE_STEPWISE = 3 // (V4L2_FRMSIZE_TYPE_STEPWISE)
)
// Cast tries to turn a v4l2_framesize.Type into a:
// v4l2_framesize.Discrete,
// v4l2_framesize.Continuous, or
// v4l2_framesize.Stepwise.
//
// Example:
//
// switch casted := frameSize.Cast().(type) {
// case v4l2_framesize.Continuous
// //@TODO
// case v4l2_framesize.Discrete:
// //@TODO
// case v4l2_framesize.Stepwise
// //@TODO
// default:
// //@TODO: Error, unknown framesize type.
// }
func (receiver Type) Cast() (interface{}, error) {
switch receiver.typ {
case const_TYPE_DISCRETE:
return *(*Discrete)(unsafe.Pointer(&receiver)), nil
case const_TYPE_CONTINUOUS:
return *(*Continuous)(unsafe.Pointer(&receiver)), nil
case const_TYPE_STEPWISE:
return *(*Stepwise)(unsafe.Pointer(&receiver)), nil
default:
return nil, fmt.Errorf("Unexpected frame size type: %d", receiver.typ)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/bdqi/go-v4l2.git
git@gitee.com:bdqi/go-v4l2.git
bdqi
go-v4l2
go-v4l2
480904891378

搜索帮助