Repository: ossrs/srs
File: trunk/3rdparty/srs-bench/gb28181/util.go (Go)

Code before:
var srsTimeout *int
var srsPublishVideoFps *int

var srsSipAddr *string
var srsSipUser *string
var srsSipRandomID *int
var srsSipDomain *string
var srsSipSvrID *string

var srsMediaTimeout *int
var srsReinviteTimeout *int
var srsPublishAudio *string
var srsPublishVideo *string

func prepareTest() (err error) {
	srsSipAddr = flag.String("srs-sip", "tcp://127.0.0.1:5060", "The SRS GB server to connect to")
	srsSipUser = flag.String("srs-stream", "3402000000", "The GB user/stream to publish")
	srsSipRandomID = flag.Int("srs-random", 10, "The GB user/stream random suffix to publish")
	srsSipDomain = flag.String("srs-domain", "3402000000", "The GB SIP domain")
	srsSipSvrID = flag.String("srs-server", "34020000002000000001", "The GB server ID for SIP")
	srsLog = flag.Bool("srs-log", false, "Whether enable the detail log")
	srsTimeout = flag.Int("srs-timeout", 11000, "For each case, the timeout in ms")
	srsMediaTimeout = flag.Int("srs-media-timeout", 2100, "PS media disconnect timeout in ms")
	srsReinviteTimeout = flag.Int("srs-reinvite-timeout", 1200, "When disconnect, SIP re-invite timeout in ms")
	srsPublishAudio = flag.String("srs-publish-audio", "avatar.aac", "The audio file for publisher.")
	srsPublishVideo = flag.String("srs-publish-video", "avatar.h264", "The video file for publisher. codec indicate by extension")
	srsPublishVideoFps = flag.Int("srs-publish-video-fps", 25, "The video fps for publisher.")

	// Should parse it first.
	flag.Parse()

	// Check file.
	tryOpenFile := func(filename string) (string, error) {
		if filename == "" {
			return filename, nil
		}

		f, err := os.Open(filename)
		if err != nil {
			nfilename := path.Join("../", filename)
			f2, err := os.Open(nfilename)
			if err != nil {
				return filename, errors.Wrapf(err, "No video file at %v or %v", filename, nfilename)
			}
			defer f2.Close()

			return nfilename, nil
		}
		defer f.Close()

		return filename, nil

Review comment (suggestion):
Change it to this:

```
The video file for publisher. Note that *.h264 is for AVC, *.h265 is for HEVC.
```

`TRANS_BY_GPT3`

Code after:
var srsTimeout *int
var srsPublishVideoFps *int

var srsSipAddr *string
var srsSipUser *string
var srsSipRandomID *int
var srsSipDomain *string
var srsSipSvrID *string

var srsMediaTimeout *int
var srsReinviteTimeout *int
var srsPublishAudio *string
var srsPublishVideo *string

func prepareTest() (err error) {
	srsSipAddr = flag.String("srs-sip", "tcp://127.0.0.1:5060", "The SRS GB server to connect to")
	srsSipUser = flag.String("srs-stream", "3402000000", "The GB user/stream to publish")
	srsSipRandomID = flag.Int("srs-random", 10, "The GB user/stream random suffix to publish")
	srsSipDomain = flag.String("srs-domain", "3402000000", "The GB SIP domain")
	srsSipSvrID = flag.String("srs-server", "34020000002000000001", "The GB server ID for SIP")
	srsLog = flag.Bool("srs-log", false, "Whether enable the detail log")
	srsTimeout = flag.Int("srs-timeout", 11000, "For each case, the timeout in ms")
	srsMediaTimeout = flag.Int("srs-media-timeout", 2100, "PS media disconnect timeout in ms")
	srsReinviteTimeout = flag.Int("srs-reinvite-timeout", 1200, "When disconnect, SIP re-invite timeout in ms")
	srsPublishAudio = flag.String("srs-publish-audio", "avatar.aac", "The audio file for publisher.")
	srsPublishVideo = flag.String("srs-publish-video", "avatar.h264", "The video file for publisher. Note that *.h264 is for AVC, *.h265 is for HEVC.")
	srsPublishVideoFps = flag.Int("srs-publish-video-fps", 25, "The video fps for publisher.")

	// Should parse it first.
	flag.Parse()

	// Check file.
	tryOpenFile := func(filename string) (string, error) {
		if filename == "" {
			return filename, nil
		}

		f, err := os.Open(filename)
		if err != nil {
			nfilename := path.Join("../", filename)
			f2, err := os.Open(nfilename)
			if err != nil {
				return filename, errors.Wrapf(err, "No video file at %v or %v", filename, nfilename)
			}
			defer f2.Close()

			return nfilename, nil
		}
		defer f.Close()

		return filename, nil