mirror of
https://github.com/pion/mediadevices.git
synced 2025-09-26 20:41:46 +08:00
add return error code
This commit is contained in:
@@ -86,15 +86,15 @@ func NewDecoder(p prop.Media) (Decoder, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (d *Decoder) Decode(data []byte) {
|
||||
func (d *Decoder) Decode(data []byte) error {
|
||||
if len(data) == 0 {
|
||||
return
|
||||
return fmt.Errorf("empty data")
|
||||
}
|
||||
status := C.decodeFrame(d.codec, (*C.uint8_t)(&data[0]), C.uint(len(data)))
|
||||
if status != C.VPX_CODEC_OK {
|
||||
fmt.Println("Decode failed", status)
|
||||
panic("Decode failed")
|
||||
return fmt.Errorf("Decode failed: %v", status)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Decoder) GetFrame() *VpxImage {
|
||||
|
@@ -479,7 +479,10 @@ func TestVP8EncodeDecode(t *testing.T) {
|
||||
defer rel()
|
||||
|
||||
// Decode the frame
|
||||
decoder.Decode(data)
|
||||
err = decoder.Decode(data)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Poll for frame with timeout
|
||||
timeout := time.After(2 * time.Second)
|
||||
|
Reference in New Issue
Block a user