i am a starter and working on MP4 file decoding.when i code as the following, it reports "Could not prove that Long :: String :: Option[Long] :: Option[java.util.UUID] :: shapeless.HNil can be converted to/from SimpleMp4BoxHeader". how can i fix this problem?
sealed trait Mp4BoxHeader {
def size: Int
def btype: String
}
case class SimpleMp4BoxHeader(size: Int, btype: String) extends Mp4BoxHeader
object SimpleMp4BoxHeader {
// val scodec = uint32 ~ ascii32
def apply(size: Int, btype: String): SimpleMp4BoxHeader = SimpleMp4BoxHeader(size, btype)
implicit def codec: Codec[SimpleMp4BoxHeader] = "simpleMp4BoxHeader" | { ("size" | uint32 ) :: ("btype" | ascii32) }.as[SimpleMp4BoxHeader]
}
It's because of
uint32
isCodec
forLong
type but yoursize
is should beInt
, take a look atscodec.codecs
package object:there are some codecs you should choose most compatible
Codec
forInt
(uint24
oruint16
), replaceuint32
to chosen and your code will compile.