Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 58 additions & 1 deletion api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,63 @@ components:
items:
$ref: '#/components/schemas/PathConf'

PathTrack:
type: object
properties:
codec:
type: string
width:
type: integer
format: int64
description: Video width in pixels (video tracks only)
height:
type: integer
format: int64
description: Video height in pixels (video tracks only)
fps:
type: string
description: Frames per second (video tracks only)
h264Profile:
type: string
description: H264 profile (H264 tracks only)
h264Level:
type: string
description: H264 level (H264 tracks only)
h265Profile:
type: string
description: H265 profile (H265 tracks only)
h265Level:
type: string
description: H265 level (H265 tracks only)
vp9Profile:
type: integer
format: int64
description: VP9 profile (VP9 tracks only)
av1Profile:
type: integer
format: int64
description: AV1 profile (AV1 tracks only)
av1Level:
type: integer
format: int64
description: AV1 level (AV1 tracks only)
av1Tier:
type: integer
format: int64
description: AV1 tier (AV1 tracks only)
channels:
type: integer
format: int64
description: Number of audio channels (audio tracks only)
sampleRate:
type: integer
format: int64
description: Audio sample rate in Hz (audio tracks only)
bitDepth:
type: integer
format: int64
description: Audio bit depth (audio tracks only)

Path:
type: object
properties:
Expand All @@ -591,7 +648,7 @@ components:
tracks:
type: array
items:
type: string
$ref: '#/components/schemas/PathTrack'
bytesReceived:
type: integer
format: int64
Expand Down
6 changes: 3 additions & 3 deletions internal/api/api_paths_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestPathsList(t *testing.T) {
Source: &defs.APIPathSourceOrReader{Type: "publisher", ID: "pub1"},
Ready: true,
ReadyTime: &now,
Tracks: []string{"H264", "Opus"},
Tracks: []defs.APIPathTrack{{Codec: "H264"}, {Codec: "Opus"}},
BytesReceived: 1000,
BytesSent: 2000,
Readers: []defs.APIPathSourceOrReader{
Expand All @@ -52,7 +52,7 @@ func TestPathsList(t *testing.T) {
Name: "test2",
ConfName: "test2",
Ready: false,
Tracks: []string{},
Tracks: []defs.APIPathTrack{},
BytesReceived: 500,
BytesSent: 100,
Readers: []defs.APIPathSourceOrReader{},
Expand Down Expand Up @@ -94,7 +94,7 @@ func TestPathsGet(t *testing.T) {
Source: &defs.APIPathSourceOrReader{Type: "rtspSession", ID: "session123"},
Ready: true,
ReadyTime: &now,
Tracks: []string{"H264", "Opus"},
Tracks: []defs.APIPathTrack{{Codec: "H264"}, {Codec: "Opus"}},
BytesReceived: 123456,
BytesSent: 789012,
Readers: []defs.APIPathSourceOrReader{
Expand Down
44 changes: 26 additions & 18 deletions internal/core/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,17 @@ func TestAPIPathsList(t *testing.T) {
Type string `json:"type"`
}

type pathTrack struct {
Codec string `json:"codec"`
}

type path struct {
Name string `json:"name"`
Source pathSource `json:"source"`
Ready bool `json:"ready"`
Tracks []string `json:"tracks"`
BytesReceived uint64 `json:"bytesReceived"`
BytesSent uint64 `json:"bytesSent"`
Name string `json:"name"`
Source pathSource `json:"source"`
Ready bool `json:"ready"`
Tracks []pathTrack `json:"tracks"`
BytesReceived uint64 `json:"bytesReceived"`
BytesSent uint64 `json:"bytesSent"`
}

type pathList struct {
Expand Down Expand Up @@ -136,7 +140,7 @@ func TestAPIPathsList(t *testing.T) {
Type: "rtspSession",
},
Ready: true,
Tracks: []string{"H264", "MPEG-4 Audio"},
Tracks: []pathTrack{{Codec: "H264"}, {Codec: "MPEG-4 Audio"}},
BytesReceived: 17,
}},
}, out)
Expand Down Expand Up @@ -184,7 +188,7 @@ func TestAPIPathsList(t *testing.T) {
Type: "rtspsSession",
},
Ready: true,
Tracks: []string{"H264", "MPEG-4 Audio"},
Tracks: []pathTrack{{Codec: "H264"}, {Codec: "MPEG-4 Audio"}},
}},
}, out)
})
Expand Down Expand Up @@ -213,7 +217,7 @@ func TestAPIPathsList(t *testing.T) {
Type: "rtspSource",
},
Ready: false,
Tracks: []string{},
Tracks: []pathTrack{},
}},
}, out)
})
Expand Down Expand Up @@ -242,7 +246,7 @@ func TestAPIPathsList(t *testing.T) {
Type: "rtmpSource",
},
Ready: false,
Tracks: []string{},
Tracks: []pathTrack{},
}},
}, out)
})
Expand Down Expand Up @@ -271,7 +275,7 @@ func TestAPIPathsList(t *testing.T) {
Type: "hlsSource",
},
Ready: false,
Tracks: []string{},
Tracks: []pathTrack{},
}},
}, out)
})
Expand All @@ -294,13 +298,17 @@ func TestAPIPathsGet(t *testing.T) {
Type string `json:"type"`
}

type pathTrack struct {
Codec string `json:"codec"`
}

type path struct {
Name string `json:"name"`
Source pathSource `json:"source"`
Ready bool `json:"Ready"`
Tracks []string `json:"tracks"`
BytesReceived uint64 `json:"bytesReceived"`
BytesSent uint64 `json:"bytesSent"`
Name string `json:"name"`
Source pathSource `json:"source"`
Ready bool `json:"Ready"`
Tracks []pathTrack `json:"tracks"`
BytesReceived uint64 `json:"bytesReceived"`
BytesSent uint64 `json:"bytesSent"`
}

var pathName string
Expand Down Expand Up @@ -329,7 +337,7 @@ func TestAPIPathsGet(t *testing.T) {
Type: "rtspSession",
},
Ready: true,
Tracks: []string{"H264"},
Tracks: []pathTrack{{Codec: "H264"}},
}, out)
} else {
res, err := hc.Get("http://localhost:9997/v3/paths/get/" + pathName)
Expand Down
6 changes: 3 additions & 3 deletions internal/core/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,11 +565,11 @@ func (pa *path) doAPIPathsGet(req pathAPIPathsGetReq) {
v := pa.readyTime
return &v
}(),
Tracks: func() []string {
Tracks: func() []defs.APIPathTrack {
if !pa.isReady() {
return []string{}
return []defs.APIPathTrack{}
}
return defs.MediasToCodecs(pa.stream.Desc.Medias)
return defs.MediasToTracks(pa.stream.Desc.Medias)
}(),
BytesReceived: func() uint64 {
if !pa.isReady() {
Expand Down
25 changes: 24 additions & 1 deletion internal/defs/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,37 @@ type APIPathSourceOrReader struct {
ID string `json:"id"`
}

// APIPathTrack is a track in a path with detailed codec information.
type APIPathTrack struct {
Codec string `json:"codec"`

// Video-specific fields (only set for video tracks)
Width *int `json:"width,omitempty"`
Height *int `json:"height,omitempty"`
FPS *string `json:"fps,omitempty"`
H264Profile *string `json:"h264Profile,omitempty"`
H264Level *string `json:"h264Level,omitempty"`
H265Profile *string `json:"h265Profile,omitempty"`
H265Level *string `json:"h265Level,omitempty"`
VP9Profile *int `json:"vp9Profile,omitempty"`
AV1Profile *int `json:"av1Profile,omitempty"`
AV1Level *int `json:"av1Level,omitempty"`
AV1Tier *int `json:"av1Tier,omitempty"`

// Audio-specific fields (only set for audio tracks)
Channels *int `json:"channels,omitempty"`
SampleRate *int `json:"sampleRate,omitempty"`
BitDepth *int `json:"bitDepth,omitempty"`
}

// APIPath is a path.
type APIPath struct {
Name string `json:"name"`
ConfName string `json:"confName"`
Source *APIPathSourceOrReader `json:"source"`
Ready bool `json:"ready"`
ReadyTime *time.Time `json:"readyTime"`
Tracks []string `json:"tracks"`
Tracks []APIPathTrack `json:"tracks"`
BytesReceived uint64 `json:"bytesReceived"`
BytesSent uint64 `json:"bytesSent"`
Readers []APIPathSourceOrReader `json:"readers"`
Expand Down
Loading