Skip to content

Commit

Permalink
Camera: Support multiple camera streaming. v5.15.5
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed May 25, 2024
1 parent e2fcc68 commit c25f81b
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 176 deletions.
1 change: 1 addition & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,7 @@ The following are the update records for the Oryx server.
* ENV: Refine the environment variables. v5.15.2
* OCR: Support OCR for image recognition. v5.15.3
* VLive: Support multiple virtual live streaming. v5.15.4
* Camera: Support multiple camera streaming. v5.15.5
* v5.14:
* Merge features and bugfix from releases. v5.14.1
* Dubbing: Support VoD dubbing for multiple languages. [v5.14.2](https://github.com/ossrs/oryx/releases/tag/v5.14.2)
Expand Down
15 changes: 11 additions & 4 deletions platform/camera-live-stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ func (v *CameraWorker) Handle(ctx context.Context, handler *http.ServeMux) error
if userConf.Platform == "" {
return errors.New("no platform")
}
if !slicesContains(allowedPlatforms, userConf.Platform) {

// Platform should be specified platforms, or starts with camera-.
if !slicesContains(allowedPlatforms, userConf.Platform) && !strings.Contains(userConf.Platform, "camera-") {
return errors.Errorf("invalid platform=%v", userConf.Platform)
}

Expand Down Expand Up @@ -323,12 +325,17 @@ func (v *CameraWorker) Handle(ctx context.Context, handler *http.ServeMux) error
}

// Check platform.
allowedPlatforms := []string{"wx", "bilibili", "kuaishou"}
if platform == "" {
return errors.New("no platform")
}
if !slicesContains(allowedPlatforms, platform) {
return errors.Errorf("invalid platform %v", platform)

if true {
allowedPlatforms := []string{"wx", "bilibili", "kuaishou"}

// Platform should be specified platforms, or starts with camera-.
if !slicesContains(allowedPlatforms, platform) && !strings.Contains(platform, "camera-") {
return errors.Errorf("invalid platform %v", platform)
}
}

// Parsed source files.
Expand Down
7 changes: 5 additions & 2 deletions platform/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,24 @@ func doMain(ctx context.Context) error {
// For system limit.
setEnvDefault("SRS_FORWARD_LIMIT", "10")
setEnvDefault("SRS_VLIVE_LIMIT", "10")
setEnvDefault("SRS_CAMERA_LIMIT", "10")

logger.Tf(ctx, "load .env as MGMT_PASSWORD=%vB, "+
"SRS_PLATFORM_SECRET=%vB, CLOUD=%v, REGION=%v, SOURCE=%v, SRT_PORT=%v, RTC_PORT=%v, "+
"NODE_ENV=%v, LOCAL_RELEASE=%v, REDIS_PASSWORD=%vB, REDIS_PORT=%v, RTMP_PORT=%v, "+
"PUBLIC_URL=%v, BUILD_PATH=%v, REACT_APP_LOCALE=%v, PLATFORM_LISTEN=%v, HTTP_PORT=%v, "+
"REGISTRY=%v, MGMT_LISTEN=%v, HTTPS_LISTEN=%v, AUTO_SELF_SIGNED_CERTIFICATE=%v, "+
"NAME_LOOKUP=%v, PLATFORM_DOCKER=%v",
"NAME_LOOKUP=%v, PLATFORM_DOCKER=%v, SRS_FORWARD_LIMIT=%v, SRS_VLIVE_LIMIT=%v, "+
"SRS_CAMERA_LIMIT=%v",
len(envMgmtPassword()), len(envApiSecret()), envCloud(),
envRegion(), envSource(), envSrtListen(), envRtcListen(),
envNodeEnv(), envLocalRelease(),
len(envRedisPassword()), envRedisPort(), envRtmpPort(), envPublicUrl(),
envBuildPath(), envReactAppLocale(), envPlatformListen(), envHttpPort(),
envRegistry(), envMgmtListen(), envHttpListen(),
envSelfSignedCertificate(), envNameLookup(),
envPlatformDocker(),
envPlatformDocker(), envForwardLimit(), envVLiveLimit(),
envCameraLimit(),
)

// Setup the base OS for redis, which should never depends on redis.
Expand Down
17 changes: 15 additions & 2 deletions platform/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,15 @@ func handleMgmtEnvs(ctx context.Context, handler *http.ServeMux) {
}
}

var cameraLimit int
if envCameraLimit() != "" {
if iv, err := strconv.ParseInt(envCameraLimit(), 10, 64); err != nil {
return errors.Wrapf(err, "parse env camera limit %v", envCameraLimit())
} else {
cameraLimit = int(iv)
}
}

platformDocker := envPlatformDocker() != "off"
candidate := envCandidate() != ""
ohttp.WriteData(ctx, w, r, &struct {
Expand All @@ -638,6 +647,8 @@ func handleMgmtEnvs(ctx context.Context, handler *http.ServeMux) {
ForwardLimit int `json:"forwardLimit"`
// The limit of the number of vLive streams.
VLiveLimit int `json:"vLiveLimit"`
// The limit of the number of IP camera streams.
CameraLimit int `json:"cameraLimit"`
}{
// Whether in docker.
MgmtDocker: true,
Expand All @@ -657,11 +668,13 @@ func handleMgmtEnvs(ctx context.Context, handler *http.ServeMux) {
ForwardLimit: forwardLimit,
// The limit of the number of vLive streams.
VLiveLimit: vLiveLimit,
// The limit of the number of IP camera streams.
CameraLimit: cameraLimit,
})

logger.Tf(ctx, "mgmt envs ok, locale=%v, platformDocker=%v, candidate=%v, rtmpPort=%v, httpPort=%v, srtPort=%v, rtcPort=%v, forwardLimit=%v, vLiveLimit=%v",
logger.Tf(ctx, "mgmt envs ok, locale=%v, platformDocker=%v, candidate=%v, rtmpPort=%v, httpPort=%v, srtPort=%v, rtcPort=%v, forwardLimit=%v, vLiveLimit=%v, cameraLimit=%v",
locale, platformDocker, candidate, envRtmpPort(), envHttpPort(),
envSrtListen(), envRtcListen(), forwardLimit, vLiveLimit,
envSrtListen(), envRtcListen(), forwardLimit, vLiveLimit, cameraLimit,
)
return nil
}(); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions platform/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,10 @@ func envVLiveLimit() string {
return os.Getenv("SRS_VLIVE_LIMIT")
}

func envCameraLimit() string {
return os.Getenv("SRS_CAMERA_LIMIT")
}

// rdb is a global redis client object.
var rdb *redis.Client

Expand Down
3 changes: 2 additions & 1 deletion platform/virtual-live-stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,9 @@ func (v *VLiveWorker) Handle(ctx context.Context, handler *http.ServeMux) error
}
// For virtual live event only.
if true {
// Platform should be specified platforms, or starts with vlive-.
allowedPlatforms := []string{"wx", "bilibili", "kuaishou"}

// Platform should be specified platforms, or starts with vlive-.
if !slicesContains(allowedPlatforms, platform) && !strings.Contains(platform, "vlive-") {
return errors.Errorf("invalid platform %v", platform)
}
Expand Down
Loading

0 comments on commit c25f81b

Please sign in to comment.