Skip to content

Conversation

@ibc
Copy link
Collaborator

@ibc ibc commented Mar 3, 2017

  • grammar: add imageattrs for a=imageattr lines (RFC 6236)
  • add export.parseImageattrParams()

@ibc ibc added the enhancement label Mar 3, 2017
lib/parser.js Outdated
list.push(params);
});

return list;
Copy link
Owner

Choose a reason for hiding this comment

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

the forEach in here should be a map so you don't have to think about the list temporary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

t.deepEqual(imageattr1RecvParams, [
{'x': 1280, 'y': 720},
{'x': 320, 'y': 180},
], 'video 1st imageattr recv params');
Copy link
Owner

Choose a reason for hiding this comment

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

yeah this is nice

lib/grammar.js Outdated
//a=imageattr:* send [x=800,y=640] recv *
//a=imageattr:100 recv [x=320,y=240]
push: 'imageattrs',
reg: /^imageattr:(\d+|\*)(?:[\s\t]+send[\s\t]+(\*|\[\S+\](?:[\s\t]+\[\S+\])?)+)?(?:[\s\t]+recv[\s\t]+(\*|\[\S+\](?:[\s\t]+\[\S+\])?)+)?/,
Copy link
Owner

Choose a reason for hiding this comment

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

that's one solid regex - i'd consider breaking this into multiple lines with comments

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A literal regular expression cannot be broken into multiple lines. The only workaround is using a RegExp object, but not sure if that would work.

Copy link
Owner

Choose a reason for hiding this comment

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

yeah, you'd have to use that instead of literal, but they are both regexes, it should work fine.

that said, it's not that bad, it just looks big at first sight due to all the repeated [\s\t] whitespace matchers. feel free to merge this now that you added the other changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Too late, done 66eeb3c :)

@clux
Copy link
Owner

clux commented Mar 3, 2017

nice addition, thanks a lot.

left some suggestions, nothing super important though.

'(?:[\\s\\t]+send[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])?)+)?' +
//recv [x=330,y=250]
'(?:[\\s\\t]+recv[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])?)+)?'
),
Copy link
Owner

Choose a reason for hiding this comment

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

nice. thanks a lot.

@clux clux merged commit 524a050 into master Mar 3, 2017
@ibc ibc deleted the imageattr branch March 3, 2017 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants