Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call support #560

Merged
merged 2 commits into from
Sep 24, 2024
Merged

Call support #560

merged 2 commits into from
Sep 24, 2024

Conversation

arugaz
Copy link
Contributor

@arugaz arugaz commented Mar 28, 2024

No description provided.

@arugaz
Copy link
Contributor Author

arugaz commented Mar 28, 2024

yes, need to test again havent commit yet

Copy link

@ahmedRSA ahmedRSA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tested call reject and this is working
thank you for contribution

@gamersindo1223
Copy link

I've found a way to offer a call on dm

func (cli *Client) OfferCall(callTo types.JID, video bool) error {
	clientID := cli.getOwnJID()
	if clientID.IsEmpty() {
		return ErrNotLoggedIn
	}
	var offerLen uint8 = 6
	if video {
		offerLen++
	}
	callID := strings.ToUpper(hex.EncodeToString(random.Bytes(16)))
	plaintext, dsmPlaintext, err := marshalMessage(callTo, &waProto.Message{Call: &waProto.Call{CallKey: random.Bytes(32)}})
	if err != nil {
		return fmt.Errorf("failed to marshal call: %w", err)
	}
	destinationNode, includeIdentity := cli.encryptMessageForDevices(context.TODO(), []types.JID{clientID, callTo}, clientID, callID, plaintext, dsmPlaintext, nil)
	if includeIdentity {
		destinationNode = append(destinationNode, cli.makeDeviceIdentityNode())
	}
	offerContent := make([]waBinary.Node, 0, offerLen)
	offerContent = append(offerContent,
		waBinary.Node{Tag: "audio", Attrs: waBinary.Attrs{"enc": "opus", "rate": "16000"}},
		waBinary.Node{Tag: "audio", Attrs: waBinary.Attrs{"enc": "opus", "rate": "8000"}},
	)
	if video {
		offerContent = append(offerContent,
			waBinary.Node{Tag: "video", Attrs: waBinary.Attrs{"orientation": "0", "screen_width": "1080", "screen_height": "2340", "device_orientation": "0", "enc": "vp8", "dec": "vp8"}},
		)
	}
	offerContent = append(offerContent,
		waBinary.Node{Tag: "capability", Attrs: waBinary.Attrs{"ver": "1"}, Content: []byte{1, 4, 255, 131, 207, 4}},
		waBinary.Node{Tag: "destination", Content: destinationNode},
		waBinary.Node{Tag: "encopt", Attrs: waBinary.Attrs{"keygen": "2"}},
		waBinary.Node{Tag: "net", Attrs: waBinary.Attrs{"medium": "3"}},
	)
	return cli.sendNode(waBinary.Node{
		Tag:   "call",
		Attrs: waBinary.Attrs{"id": cli.GenerateMessageID(), "to": callTo},
		Content: []waBinary.Node{{
			Tag:     "offer",
			Attrs:   waBinary.Attrs{"call-id": callID, "call-creator": clientID},
			Content: offerContent,
		}},
	})
}```

@arugaz
Copy link
Contributor Author

arugaz commented Mar 30, 2024

yeah, thats what was done 4 months ago, im still looking for group call

@ahmedRSA
Copy link

ahmedRSA commented Apr 1, 2024

I've found a way to offer a call on dm

func (cli *Client) OfferCall(callTo types.JID, video bool) error {
	clientID := cli.getOwnJID()
	if clientID.IsEmpty() {
		return ErrNotLoggedIn
	}
	var offerLen uint8 = 6
	if video {
		offerLen++
	}
	callID := strings.ToUpper(hex.EncodeToString(random.Bytes(16)))
	plaintext, dsmPlaintext, err := marshalMessage(callTo, &waProto.Message{Call: &waProto.Call{CallKey: random.Bytes(32)}})
	if err != nil {
		return fmt.Errorf("failed to marshal call: %w", err)
	}
	destinationNode, includeIdentity := cli.encryptMessageForDevices(context.TODO(), []types.JID{clientID, callTo}, clientID, callID, plaintext, dsmPlaintext, nil)
	if includeIdentity {
		destinationNode = append(destinationNode, cli.makeDeviceIdentityNode())
	}
	offerContent := make([]waBinary.Node, 0, offerLen)
	offerContent = append(offerContent,
		waBinary.Node{Tag: "audio", Attrs: waBinary.Attrs{"enc": "opus", "rate": "16000"}},
		waBinary.Node{Tag: "audio", Attrs: waBinary.Attrs{"enc": "opus", "rate": "8000"}},
	)
	if video {
		offerContent = append(offerContent,
			waBinary.Node{Tag: "video", Attrs: waBinary.Attrs{"orientation": "0", "screen_width": "1080", "screen_height": "2340", "device_orientation": "0", "enc": "vp8", "dec": "vp8"}},
		)
	}
	offerContent = append(offerContent,
		waBinary.Node{Tag: "capability", Attrs: waBinary.Attrs{"ver": "1"}, Content: []byte{1, 4, 255, 131, 207, 4}},
		waBinary.Node{Tag: "destination", Content: destinationNode},
		waBinary.Node{Tag: "encopt", Attrs: waBinary.Attrs{"keygen": "2"}},
		waBinary.Node{Tag: "net", Attrs: waBinary.Attrs{"medium": "3"}},
	)
	return cli.sendNode(waBinary.Node{
		Tag:   "call",
		Attrs: waBinary.Attrs{"id": cli.GenerateMessageID(), "to": callTo},
		Content: []waBinary.Node{{
			Tag:     "offer",
			Attrs:   waBinary.Attrs{"call-id": callID, "call-creator": clientID},
			Content: offerContent,
		}},
	})
}```

hi is this possible to send call for only like 5 second
or X second 1, 2second ?

@gamersindo1223
Copy link

no Idea

@ahmedRSA
Copy link

ahmedRSA commented May 1, 2024

this stop working for some reason anyones having asame problem ?

@purpshell
Copy link
Contributor

change commit name to feature: call rejection function

@ahmedRSA
Copy link

ahmedRSA commented Aug 6, 2024

will this merge ?

@mateusfmello
Copy link

change commit name to feature: call rejection function

@purpshell @tulir

If I change the title of the PR, will you merge the feature?

I need this implementation and if @arugaz doesn't update the title, I'll implement it myself with a new title to merge into the project.

Copy link

@mateusfmello mateusfmello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented the modifications and it works perfectly.

call.go Outdated Show resolved Hide resolved
@tulir tulir marked this pull request as ready for review September 24, 2024 12:34
@tulir tulir merged commit 705b718 into tulir:main Sep 24, 2024
2 checks passed
crazycodezombie pushed a commit to crazycodezombie/whatsmeow that referenced this pull request Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants