Skip to content

Commit

Permalink
Merge branch 'new_checkliveinterrupt'
Browse files Browse the repository at this point in the history
  • Loading branch information
Phuocpr1998 committed Dec 21, 2020
2 parents 4e49a60 + 536acff commit f3e7ac4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
10 changes: 6 additions & 4 deletions avcodec/avcodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@ var (
type CodecID C.enum_AVCodecID

const (
CodecIDNone CodecID = C.AV_CODEC_ID_NONE
CodecIDMJpeg CodecID = C.AV_CODEC_ID_MJPEG
CodecIDLJpeg CodecID = C.AV_CODEC_ID_LJPEG
CodecIDAAC CodecID = C.AV_CODEC_ID_AAC
CodecIDNone CodecID = C.AV_CODEC_ID_NONE
CodecIDMJpeg CodecID = C.AV_CODEC_ID_MJPEG
CodecIDLJpeg CodecID = C.AV_CODEC_ID_LJPEG
CodecIDAAC CodecID = C.AV_CODEC_ID_AAC
CodecIDPCMALAW CodecID = C.AV_CODEC_ID_PCM_ALAW
CodecIDPCMMULAW CodecID = C.AV_CODEC_ID_PCM_MULAW
)

type Flags int64
Expand Down
15 changes: 11 additions & 4 deletions avformat/avformat.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ package avformat
//}
//
//static void free_pointer(void *ptr) {
// av_freep(ptr);
// av_freep(&ptr);
//}
//
//static AVIOInterruptData* createInterruptData() {
// return (AVIOInterruptData*) av_malloc(sizeof(AVIOInterruptData*));
// AVIOInterruptData* interruptData = (AVIOInterruptData*) av_malloc(sizeof(AVIOInterruptData*));
// interruptData->streamName = NULL;
// return interruptData;
//}
//
//static char* avSdpCreate(AVFormatContext *ps) {
Expand Down Expand Up @@ -1072,6 +1074,9 @@ type IOInterruptData struct {
func (interruptData *IOInterruptData) SetStreamName(streamName string) {
cStreamName := C.CString(streamName)
cAVIOInterruptData := (*C.AVIOInterruptData)(unsafe.Pointer(interruptData.CAVIOInterruptData))
if unsafe.Pointer((*C.AVIOInterruptData)(cAVIOInterruptData).streamName) != nil {
C.free(unsafe.Pointer((*C.AVIOInterruptData)(cAVIOInterruptData).streamName))
}
cAVIOInterruptData.streamName = cStreamName
}

Expand All @@ -1084,8 +1089,10 @@ func (interruptData *IOInterruptData) SetLastTimestamp(lastTimestamp int) {

func (interruptData *IOInterruptData) Free() {
cAVIOInterruptData := unsafe.Pointer(interruptData.CAVIOInterruptData)
C.free(unsafe.Pointer((*C.AVIOInterruptData)(cAVIOInterruptData).streamName))
C.av_free(cAVIOInterruptData)
if unsafe.Pointer((*C.AVIOInterruptData)(cAVIOInterruptData).streamName) != nil {
C.free(unsafe.Pointer((*C.AVIOInterruptData)(cAVIOInterruptData).streamName))
}
C.free_pointer(cAVIOInterruptData)
}

func NewIOInterruptDataFromC() *IOInterruptData {
Expand Down

0 comments on commit f3e7ac4

Please sign in to comment.