Skip to content

Commit

Permalink
Enable ffmpeg opus for clion.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Nov 16, 2023
1 parent 3164969 commit 975ef2f
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 2 deletions.
83 changes: 83 additions & 0 deletions trunk/3rdparty/srs-bench/srs/rtmp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,3 +639,86 @@ func TestRtmpPublish_HttpFlvPlayNoVideo(t *testing.T) {
t.Errorf("err %+v", err)
}
}

func TestRtmpPublish_HttpFlvPlayNoVideo_PublishFirst(t *testing.T) {
ctx := logger.WithContext(context.Background())
ctx, cancel := context.WithTimeout(ctx, time.Duration(*srsTimeout)*time.Millisecond)

var r0, r1 error
err := func() error {
publisher := NewRTMPPublisher()
defer publisher.Close()

// Set publisher to drop video.
publisher.hasVideo = false

player := NewFLVPlayer()
defer player.Close()

// Connect to RTMP URL.
streamSuffix := fmt.Sprintf("rtmp-regression-%v-%v", os.Getpid(), rand.Int())
rtmpUrl := fmt.Sprintf("rtmp://%v/live/%v", *srsServer, streamSuffix)
flvUrl := fmt.Sprintf("http://%v/live/%v.flv", *srsHttpServer, streamSuffix)

if err := publisher.Publish(ctx, rtmpUrl); err != nil {
return err
}

if err := player.Play(ctx, flvUrl); err != nil {
return err
}

// Check packets.
var wg sync.WaitGroup
defer wg.Wait()

publisherReady, publisherReadyCancel := context.WithCancel(context.Background())
wg.Add(1)
go func() {
defer wg.Done()
time.Sleep(30 * time.Millisecond) // Wait for publisher to push sequence header.
publisherReadyCancel()
}()

wg.Add(1)
go func() {
defer wg.Done()
<-publisherReady.Done()

var nnPackets int
player.onRecvHeader = func(hasAudio, hasVideo bool) error {
return nil
}
player.onRecvTag = func(tp flv.TagType, size, ts uint32, tag []byte) error {
if tp == flv.TagTypeVideo {
return errors.New("should no video")
}
logger.Tf(ctx, "got %v tag, %v %vms %vB", nnPackets, tp, ts, len(tag))
if nnPackets += 1; nnPackets > 50 {
cancel()
}
return nil
}
if r1 = player.Consume(ctx); r1 != nil {
cancel()
}
}()

wg.Add(1)
go func() {
defer wg.Done()
publisher.onSendPacket = func(m *rtmp.Message) error {
time.Sleep(1 * time.Millisecond)
return nil
}
if r0 = publisher.Ingest(ctx, *srsPublishAvatar); r0 != nil {
cancel()
}
}()

return nil
}()
if err := filterTestError(ctx.Err(), err, r0, r1); err != nil {
t.Errorf("err %+v", err)
}
}
4 changes: 2 additions & 2 deletions trunk/ide/srs_clion/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ ProcessorCount(JOBS)
# We should always configure SRS for switching between branches.
IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
EXECUTE_PROCESS(
COMMAND ./configure --osx --srt=on --gb28181=on --apm=on --h265=on --utest=on --jobs=${JOBS}
COMMAND ./configure --osx --srt=on --gb28181=on --apm=on --h265=on --utest=on --ffmpeg-opus=on --jobs=${JOBS}
WORKING_DIRECTORY ${SRS_DIR} RESULT_VARIABLE ret)
ELSE ()
EXECUTE_PROCESS(
COMMAND ./configure --srt=on --gb28181=on --apm=on --h265=on --utest=on --jobs=${JOBS}
COMMAND ./configure --srt=on --gb28181=on --apm=on --h265=on --utest=on --ffmpeg-opus=on --jobs=${JOBS}
WORKING_DIRECTORY ${SRS_DIR} RESULT_VARIABLE ret)
ENDIF ()
if(NOT ret EQUAL 0)
Expand Down

0 comments on commit 975ef2f

Please sign in to comment.