Skip to content

Commit

Permalink
vcap/pipewire: Add target option
Browse files Browse the repository at this point in the history
  • Loading branch information
mpiatka committed Oct 16, 2023
1 parent 6b3a7f6 commit c9f378d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/video_capture/pipewire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ struct screen_cast_session {
std::string restore_file = "";
uint32_t fps = 0;
bool crop = true;
std::string target = "";
} user_options;

struct pw_{
Expand Down Expand Up @@ -390,11 +391,18 @@ static int start_pipewire(screen_cast_session &session)

assert(core != nullptr);

session.pw.stream = pw_stream_new(core, "my_screencast", pw_properties_new(
auto props = pw_properties_new(
PW_KEY_MEDIA_TYPE, "Video",
PW_KEY_MEDIA_CATEGORY, "Capture",
PW_KEY_MEDIA_ROLE, "Screen",
nullptr));
nullptr);

if(!session.user_options.target.empty()){
pw_properties_set(props, STREAM_TARGET_PROPERTY_KEY, session.user_options.target.c_str());
}

session.pw.stream = pw_stream_new(core, "ug_screencapture", props);

assert(session.pw.stream != nullptr);
pw_stream_add_listener(session.pw.stream, &session.pw.stream_listener, &stream_events, &session);

Expand Down Expand Up @@ -512,6 +520,9 @@ static int parse_params(struct vidcap_params *params, screen_cast_session &sessi
}else if(name == "restore"){
session.user_options.restore_file = value;
continue;
} else if(name =="target"){
session.user_options.target = value;
continue;
}
}

Expand Down

0 comments on commit c9f378d

Please sign in to comment.